Datasheet
BOE Shield-Bot Navigation • Chapter 4
Robotics with the BOE Shield-Bot • 107
Your Turn – Adjusting Distance
Want to change the distance traveled? Just change the time in delay(3000). For
example,
delay(1500) will make the BOE Shield-Bot go for only half the time, which in turn
will make it travel only half as far. Likewise,
delay(6000) will make it go for twice the time,
and therefore twice the distance.
Change
delay(3000) to delay(1500) and re-load the sketch. Did the BOE
Shield-Bot travel only half the distance?
Moving Backward, Rotating, and Pivoting
All it takes to get other motions out of your BOE Shield-Bot are different combinations
of
us parameters in your servoLeft and servoRight writeMicroseconds calls. For
example, these two calls will make your BOE Shield-Bot go backwards:
// Full speed backwards
servoLeft.writeMicroseconds(1300); // Left wheel clockwise
servoRight.writeMicroseconds(1700); // Right wheel counterclockwise
These two calls will make your BOE Shield-Bot rotate in place to make a left turn:
// Turn left in place
servoLeft.writeMicroseconds(1300); // Left wheel clockwise
servoRight.writeMicroseconds(1300); // Right wheel clockwise
These two calls will make your BOE Shield-Bot rotate in place for a right turn:
// Turn right in place
servoLeft.writeMicroseconds(1700); // Left wheel counterclockwise
servoRight.writeMicroseconds(1700); // Right wheel counterclockwise
Let’s combine all these commands into a single sketch that makes the BOE Shield-Bot move
forward, turn left, turn right, then move backward.
Example Sketch: ForwardLeftRightBackward
Create, save, and run the ForwardLeftRightBackward sketch.
Verify that the BOE Shield-Bot makes the forward-left-right-backward motions.
// Robotics with the BOE Shield - ForwardLeftRightBackward
// Move forward, left, right, then backward for testing and tuning.
#include <Servo.h> // Include servo library
Servo servoLeft; // Declare left and right servos