Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Robotics with the Board of Education Shield for Arduino

Robotics with the Board of Education Shield for Arduino

Moving Backward, Rotating, and Pivoting

All it takes to get other motions out of your BOE Shield-Bot are different combinations of us parameters in your servoLeft and servoRight writeMicroseconds calls.  For example, these two calls will make your BOE Shield-Bot go backwards:

 // Full speed backwards
 servoLeft.writeMicroseconds(1300);   // Left wheel clockwise
 servoRight.writeMicroseconds(1700);  // Right wheel counterclockwise

These two calls will make your BOE Shield-Bot rotate in place to make a left turn:

 // Turn left in place
 servoLeft.writeMicroseconds(1300);   // Left wheel clockwise
 servoRight.writeMicroseconds(1300);  // Right wheel clockwise

These two calls will make your BOE Shield-Bot rotate in place for a right turn:

 // Turn right in place
 servoLeft.writeMicroseconds(1700);   // Left wheel counterclockwise
 servoRight.write Microseconds(1700); // Right wheel counterclockwise

Let’s combine all these commands into a single sketch that makes the BOE Shield-Bot move forward, turn left, turn right, then move backward.

Example Sketch: ForwardLeftRightBackward

  • Enter, save, and upload ForwardLeftRightBackward.
  • Verify that the BOE Shield-Bot makes the forward-left-right-backward motions.
// 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
}

TIP — To enter this sketch quickly, use the Arduino software’s Edit menu tools (Copy and Paste) to make four copies of the four lines that make up a maneuver (comment, servoLeft.writeMicroseconds, servoRight.writeMicroseconds, and delay).  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

 // Pivot forward-right
 servoLeft.writeMicroseconds(1700);   // Left wheel counterclockwise
 servoRight.writeMicroseconds(1500);  // Right wheel stop

 // Pivot backward-left
 servoLeft.writeMicroseconds(1500);   // Left wheel stop
 servoRight.writeMicroseconds(1700);  // Right wheel counterclockwise

 // Pivot backward-right
 servoLeft.writeMicroseconds(1300);     // Left wheel clockwise
 servoRight.writeMicroseconds(1500);    // Right wheel stop
  • Save ForwardLeftRightBackward as PivotTests.
  • Change the us parameter in each writeMicroseconds call so the sketch will perform all four pivot maneuvers: forward, left, right, backward.
  • Run the modified sketch and verify that the different pivot actions work. 
  • Try experimenting with the delay calls for each maneuver so that each one runs long enough to execute a 90° turn.

Printer-friendly version
How ForwardThreeSeconds Works
Prev
Activity 2: Tuning the Basic Maneuvers
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn • Built with GeneratePress