Datasheet

Chapter 4 • BOE Shield-Bot Navigation
108Robotics with the BOE Shield-Bot
Servo servoRight;
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
// Full speed forward
servoLeft.writeMicroseconds(1700); // Left wheel counterclockwise
servoRight.writeMicroseconds(1300); // Right wheel clockwise
delay(2000); // ...for 2 seconds
// Turn left in place
servoLeft.writeMicroseconds(1300); // Left wheel clockwise
servoRight.writeMicroseconds(1300); // Right wheel clockwise
delay(600); // ...for 0.6 seconds
// Turn right in place
servoLeft.writeMicroseconds(1700); // Left wheel counterclockwise
servoRight.writeMicroseconds(1700); // Right wheel counterclockwise
delay(600); // ...for 0.6 seconds
// Full speed backward
servoLeft.writeMicroseconds(1300); // Left wheel clockwise
servoRight.writeMicroseconds(1700); // Right wheel counterclockwise
delay(2000); // ...for 2 seconds
servoLeft.detach(); // Stop sending servo signals
servoRight.detach();
}
void loop() // Main loop auto-repeats
{ // Empty, nothing needs repeating
}
QUICK TIPTo enter this sketch quickly, copy and paste to make four copies of the four lines
that make up a maneuver. Then, modify each one with individual values.
Your Turn Pivoting
You can make the BOE Shield-Bot turn by pivoting around one wheel. The trick is to keep
one wheel still while the other rotates. Here are the four routines for forward and backward
pivot turns:
// Pivot forward-left
servoLeft.writeMicroseconds(1500); // Left wheel stop
servoRight.writeMicroseconds(1300); // Right wheel clockwise