Datasheet

BOE Shield-Bot Navigation • Chapter 4
Robotics with the BOE Shield-Bot 145
{
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
// Arc to the right
servoLeft.writeMicroseconds(1600); // Left wheel counterclockwise
servoRight.writeMicroseconds(1438); // Right wheel clockwise slower
delay(25500); // ...for 25.5 seconds
servoLeft.detach(); // Stop sending servo signals
servoRight.detach();
}
void loop() // Main loop auto-repeats
{ // Nothing needs repeating
}
For the triangle, first calculate the required travel time in ms for a 1 meter or 1 yard
straight line, as in Question 4, and fine-tune for your BOE Shield-Bot and particular
surface. The BOE Shield-Bot must travel 1 meter/yard forward, and then make a
120° turn, repeated three times for the three sides of the triangle. You may have to
adjust the delay call in the Turn Left 120° routine to get a precise 120° turn.
// Robotics with the BOE Shield - Chapter 4, project 2 - Triangle
// BOE Shield-Bot navigates a triangle with 1 yard sides and 120
// degree angles. Go straight 1 yard, turn 120 degrees, repeat 3 times
#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
for(int index = 1; index <= 3; index++)
{
// Full speed forward
servoLeft.writeMicroseconds(1700); // Left wheel counterclockwise
servoRight.writeMicroseconds(1300); // Right wheel clockwise slower
delay(5500); // ...for 5.5 seconds