Let’s try the ForwardLeftRightBackward.ino sketch from http://learn.parallax.com/node/219 in Robotics with the BOE Shield-Bot web book. You might have noticed that the second to last call in the previous sketch: Arlo.writePulseMode().. That switched the Arlo’s DHB-10 from serial communication mode to pulse mode in preparation for this sketch. When the Arlo’s DHB-10 starts up, it automatically goes into pulse mode. So, another option for switching a sketch out of serial communication mode is to simply restart the DHB-10. You can do that by either pressing and releasing its reset button or turning Motors power off and back on.
The sketch would make a BOE Shield-Bot turn about 90 degrees, but not so with the Arlo.
In the More Precise Maneuvers with Encoders section, we’ll get those 90° turns on the first try!
// Robotics with the BOE Shield - ForwardLeftRightBackward // Move forward, left, right, then backward for testing and tuning. #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(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 }