Datasheet

BOE Shield-Bot Navigation • Chapter 4
Robotics with the BOE Shield-Bot 109
// Pivot forward-right
servoLeft.writeMicroseconds(1700); // Left wheel counterclockwise
servoRight.writeMicroseconds(1500); // Right wheel stop
// Pivot backward-left
servoLeft.writeMicroseconds(1500); // Left wheel stop
servoRight.writeMicroseconds(1700); // Right wheel counterclockwise
// Pivot backward-right
servoLeft.writeMicroseconds(1300); // Left wheel clockwise
servoRight.writeMicroseconds(1500); // Right wheel stop
Save ForwardLeftRightBackward as PivotTests.
Change the
us parameter in each writeMicroseconds call so the sketch will
perform all four pivot maneuvers: forward, left, right, backward.
Run the modified sketch and verify that the different pivot actions work.
Try experimenting with the
delay calls for each maneuver so that each one runs
long enough to execute a 90° turn.
Activity 2: Tuning the Basic Maneuvers
Imagine writing a sketch that instructs your BOE Shield-Bot to travel full-speed forward for
fifteen seconds. What if your robot curves slightly to the left or right during its travel, when
it’s supposed to be traveling straight ahead? There’s no need to take the BOE Shield-Bot
back apart and re-adjust the servos with a screwdriver to fix this. You can simply adjust the
sketch slightly to get both wheels traveling the same speed. While the screwdriver approach
could be considered a hardware adjustment, the programming approach would be a software
adjustment.
Straightening the Shield-Bot’s Path
So, would your BOE Shield-Bot travel in an arc instead of in a straight line? Top speed varies
from one servo to the next, so one wheel is likely to rotate a little faster than the other,
causing the BOE Shield-Bot to make a gradual turn.
To correct this, the first step is to examine your BOE Shield-Bot’s forward travel for a longer
period of time to see if it is curving, which way, and how much.
Example Sketch: ForwardTenSeconds
Open ForwardThreeSeconds and re-save it as ForwardTenSeconds.
Change
delay(3000) to delay(10000), and update the title and comments too.
Set the power switch to 1, run the sketch, then disconnect the USB cable.