Datasheet

BOE Shield-Bot Navigation • Chapter 4
Robotics with the BOE Shield-Bot 125
Cut the function calls to forward(2000), turnLeft(600), turnRight(600),
and
backward(2000) out of the setup function and paste them into the loop
function. It should look like this when you’re done:
void setup() // Built-in initialization block
{
tone(4, 3000, 1000); // Play tone for 1 second
delay(1000); // Delay to finish tone
servoLeft.attach(13); // Attach left signal to pin 13
servoRight.attach(12); // Attach right signal to pin 12
// disableServos(); // Stay still indefinitely
}
void loop() // Main loop auto-repeats
{
forward(2000); // Go forward for 2 seconds
turnLeft(600); // Turn left for 0.6 seconds
turnRight(600); // Turn right for 0.6 seconds
backward(2000); // Go backward for 2 seconds
Run the modified sketch and verify that it repeats the sequence of four
maneuvers indefinitely.
Activity 6: Custom Maneuver Function
The last sketch, MovementsWithSimpleFunctions, was kind of long and clunky. And, the four
functions it uses to drive the robot are almost the same. The TestManeuverFunction sketch
takes advantage of those function's similarities and streamlines the code.
TestManeuverFunction has a single function for motion named
maneuver that accepts three
parameters:
speedLeft, speedRight, and msTime:
void maneuver(int speedLeft, int speedRight, int msTime)
The rules for speedLeft and speedRight are easy to remember. With this maneuver
function you don’t have to think about clockwise and counterclockwise rotation anymore.
positive values for moving the robot forward
negative values for moving the robot backward
200 for full speed forward
200 for full speed backward
0 for stop
100 to 100 range for linear speed control
The rules for
msTime are: