Datasheet

Chapter 4 • BOE Shield-Bot Navigation
124Robotics with the BOE Shield-Bot
}
void forward(int time) // Forward function
{
servoLeft.writeMicroseconds(1700); // Left wheel counterclockwise
servoRight.writeMicroseconds(1300); // Right wheel clockwise
delay(time); // Maneuver for time ms
}
void turnLeft(int time) // Left turn function
{
servoLeft.writeMicroseconds(1300); // Left wheel clockwise
servoRight.writeMicroseconds(1300); // Right wheel clockwise
delay(time); // Maneuver for time ms
}
void turnRight(int time) // Right turn function
{
servoLeft.writeMicroseconds(1700); // Left wheel counterclockwise
servoRight.writeMicroseconds(1700); // Right wheel counterclockwise
delay(time); // Maneuver for time ms
}
void backward(int time) // Backward function
{
servoLeft.writeMicroseconds(1300); // Left wheel clockwise
servoRight.writeMicroseconds(1700); // Right wheel counterclockwise
delay(time); // Maneuver for time ms
}
void disableServos() // Halt servo signals
{
servoLeft.detach(); // Stop sending servo signals
servoRight.detach();
}
You should recognize the pattern of movement your BOE Shield-Bot makes; it is the same
one made by the ForwardLeftRightBackward sketch. This is a second example of the many
different ways to structure a sketch that will result in the same movements. There will be a
few more examples before the end of the chapter.
Your Turn Move Function Calls into loop
Want to keep performing that set of four maneuvers over and over again? Just move those
four maneuvering function calls from the
setup function into the loop function. Try this:
Save the sketch under a new name, like MovementsWithFunctionsInLoop
Comment out the
disableServos() function call that’s in setup by placing two
forward slashes to its left, like this:
// disable Servos
Remove the
// Empty… comment from the loop functionit won’t be correct!