Skip to content

Commit

Permalink
example bot can hold a heading now!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
swit committed Jun 6, 2013
1 parent 2f8ab5a commit f39cb3c
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions code/example_bot/example_bot.ino
Expand Up @@ -15,6 +15,7 @@ unsigned int speed_L = LEFT_STOP;
unsigned int speed_R = RIGHT_STOP;
unsigned long timeLastServoUpdate = 0;
unsigned long timeToStop = 0;
unsigned long timeToGo = 0;
unsigned long timeLastStatus = 0;

RKF_Radio radio;
Expand Down Expand Up @@ -123,23 +124,27 @@ void loop(){
//Turn left
rot_amount = (16+abs(hdiff))%16;
if (rot_amount > 0){
//speed_L = throttle(LEFT_REV, LEFT_STOP, 0.1);
//speed_R = throttle(RIGHT_FWD, RIGHT_STOP, 0.1);
//timeToStop = millis() + 200;
//turnleft then wait a little bit
if(timeToStop == 0 and timeToGo<millis()){
speed_L = throttle(LEFT_REV, LEFT_STOP, 0.1);
speed_R = throttle(RIGHT_FWD, RIGHT_STOP, 0.1);
timeToStop = millis() + 100;
timeToGo = timeToStop + 1000;
}
}
//Serial.print("LEFT ");
//Serial.println(rot_amount);

}else{
//Turn right
rot_amount = (16-abs(hdiff))%16;
if (rot_amount > 0){
//speed_L = throttle(LEFT_FWD, LEFT_STOP, 0.1);
//speed_R = throttle(RIGHT_REV, RIGHT_STOP, 0.1);
//timeToStop = millis() + 200;
//turnleft then wait a little bit
if(timeToStop == 0 and timeToGo<millis()){
speed_L = throttle(LEFT_FWD, LEFT_STOP, 0.1);
speed_R = throttle(RIGHT_REV, RIGHT_STOP, 0.1);
timeToStop = millis() + 100;
timeToGo = timeToStop + 1000;
}
}
//Serial.print("RIGHT ");
//Serial.println(rot_amount);
}
}

Expand Down

0 comments on commit f39cb3c

Please sign in to comment.