Activity 1: Basic BOE Shield-Bot Maneuvers
Moving Forward
Have you ever thought about what direction a car’s wheels have to turn to propel it forward? The wheels turn opposite directions on opposite sides of the car. Likewise, to make the BOE Shield-Bot go forward, its left wheel has to turn counterclockwise, but its right wheel has to turn clockwise.

Remember that a sketch can use the Servo library’s writeMicroseconds function to control the speed and direction of each servo. Then, it can use the delay function to keep the servos running for certain amounts of time before choosing new speeds and directions. Here’s an example that will make the BOE Shield-Bot roll forward for about three seconds, and then stop.
Example Sketch: ForwardThreeSeconds
- Make sure the BOE Shield’s power switch is set to 1 and the battery pack is plugged into the Arduino.
- Enter, save, and upload ForwardThreeSeconds to the Arduino.
- Disconnect the programing cable and put the BOE Shield-Bot on the floor.
- While holding down the Reset button, move the switch to position 3, and then let go. The BOE Shield-Bot should drive forward for three seconds.
// Robotics with the BOE Shield - ForwardThreeSeconds
// Make the BOE Shield-Bot roll forward for three seconds, then stop.
#include <Servo.h> // Include servo library
Servo servoLeft; // Declare left and right servos
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(3000); // ...for 3 seconds
servoLeft.detach(); // Stop sending servo signals
servoRight.detach();
}
void loop() // Main loop auto-repeats
{ // Empty, nothing needs repeating
}