Datasheet

BOE Shield-Bot Navigation • Chapter 4
Robotics with the BOE Shield-Bot 135
}
void loop() // Main loop auto-repeats
{ // Empty, nothing needs repeating
}
void maneuver(int speedLeft, int speedRight, int msTime)
{
// speedLeft, speedRight ranges: Backward Linear Stop Linear Forward
// -200 -100......0......100 200
servoLeft.writeMicroseconds(1500 + speedLeft); // Left servo speed
servoRight.writeMicroseconds(1500 - speedRight); // right servo speed
if(msTime==-1) // if msTime = -1
{
servoLeft.detach(); // Stop servo signals
servoRight.detach();
}
delay(msTime); // Delay for msTime
}
Did your BOE Shield-Bot perform the familiar forward-left-right-backward-stop sequence of
movements? Are you thoroughly bored with it by now? Do you want to see your BOE
Shield-Bot do something else, or to choreograph your own routine?
Your Turn Add Maneuvers to the List
Here’s an example of a longer list you can try. It does the four pivots after the forward-left-
right-backward sequence. In this example, when
index is 4, it’ll use the first number of the
second line of each array. When
index is 5, it’ll use the second number on the second line of
each array, and so on. Notice that each list of comma-separated array elements is contained
within curly braces
{ }, and it doesn’t matter whether that list is all on one line or spanning
multiple lines.
int speedsLeft[] = {200, -200, 200, -200,
0, 200, -200, 0, 0};
int speedsRight[] = {200, 200, -200, -200,
200, 0, 0, -200, 0};
int times[] = {2000, 600, 600, 2000,
1000, 1000, 1000, 1000, -1};
Save ManeuverSequence as ManeuverSequenceExpanded.
Change the array so it matches the examples with 9 elements above.
Run the modified sketch and verify that the pivot sequence gets executed after
the forward-left-right-backward sequence.