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

Arlo with an Arduino Uno & BOE Shield Brain

Curriculum

  • 1 Section
  • 14 Lessons
  • Lifetime
Expand all sectionsCollapse all sections
  • Arlo with an Arduino Uno & BOE Shield Brain
    14
    • 1.1
      ArloRobot Arduino Library
    • 1.2
      Connect BOE Shield to DHB-10
    • 1.3
      Test Shield Electrical Connections
    • 1.4
      Clear the Arduino Sketch
    • 1.5
      Test Arduino to DHB-10 Communication
    • 1.6
      Test BOE Shield Arlo Motor Connections
    • 1.7
      Test BOE Shield Arlo Encoder Connections
    • 1.8
      Try & Tune Some BOE Shield-Bot Code
    • 1.9
      Increase BOE Shield Arlo’s Top Speed
    • 1.10
      Control BOE Shield Arlo with the Terminal
    • 1.11
      More Precise BOE Shield Maneuvers with Encoders
    • 1.12
      Connect & Test BOE Shield + Arlo Ping))) Sensors
    • 1.13
      BOE Shield + Arlo Control System Adjustments
    • 1.14
      Troubleshooting Your Arlo + BOE Shield

More Precise BOE Shield Maneuvers with Encoders

More Precise Maneuvers with Encoders

As mentioned earlier, the Arlo has encoders that track distance in 144th increments of a full wheel rotation.  These increments are commonly called “counts”, and the Arlo’s encoders send 144 counts per wheel revolution.  The Arlo’s encoders are quadrature, meaning that the two encoder sensors are offset by ¼ of a count.  The most important feature of quadrature encoding is that DHB-10 can determine which direction a wheel is turning by monitoring  the pattern of low-high-low transitions for both sensors, the.  For a given wheel, 144 counts would mean a full forward rotation, and -144 counts would mean a full backward rotation.

The Arlo’s DHB-10 motor controller has a built-in control system that uses the encoder outputs to control motor speed and distance as well as monitor motor position.  The ArloRobot library has functions your sketch can call to both control speed and distance traveled, as well as poll current speed and distance.

NOTE: For more info on ArloRobot functions for Arduino, see the ArloRobot API (coming soon).

IMPORTANT: Make sure your sketch gives each maneuver enough time to finish before issuing a new distance command.

 

Distance Control 

This example sketch uses the ArloRobot writeCounts function to tell the Arlo’s DHB-10 controller to make the Arlo travel certain numbers of encoder ticks, and the readCountsLeft and readCountsRight functions to check the actual distances traveled between each maneuver. 

  • Set power: MAIN (on), MOTORS (off), BOE Shield (position-2)
  • Upload Arlo-Distance-Maneuvers.ino.
  • Don’t worry about the communication error message because Motors power is off.
  • Turn all power off, unplug programming cable, and take to your Arlo navigation area.
  • Turn MAIN and MOTORS power on.
  • Set the BOE Shield power switch to 2.
  • Verify that the Arlo goes forward, turns left, then right, then left, then backs up to near where it started.
/*
Arlo-Distance-Maneuvers
Examples that use serial communication to make the arlo travel in certain
distances.
*/


#include <ArloRobot.h>                        // Include Arlo library
#include <SoftwareSerial.h>                   // Include SoftwareSerial library

// Arlo and serial objects required
ArloRobot Arlo;                               // Arlo object
SoftwareSerial ArloSerial(12, 13);            // Serial in I/O 12, out I/O 13

int countsLeft, countsRight;                  // Encoder counting variables
void setup()                                  // Setup function
{
  tone(4, 3000, 2000);                        // Piezospeaker beep
  Serial.begin(9600);                         // Start terminal serial port
  Serial.println("Program running...");       // Display starting message
 
  ArloSerial.begin(19200);                    // Start DHB-10 serial com
  Arlo.begin(ArloSerial);                     // Pass to Arlo object

  Arlo.clearCounts();                         // Clear encoder counts

  Arlo.writeCounts(144, 144);                 // Go forward 144 counts
  delay(3000);                                // Wait three seconds
  displayDistances();                         // Display encoder counts

  Arlo.writeCounts(-72, 72);                  // Turn left 72 counts
  delay(2000);                                // Wait two seconds
  displayDistances();                         // Display encoder counts

  Arlo.writeCounts(72, -72);                  // Turn right 72 counts
  delay(2000);                                // Wait 2 seconds
  displayDistances();                         // Display encoder counts

  Arlo.writeCounts(-144, -144);               // Back up 144 counts
  delay(3000);                                // Wait three seconds
  displayDistances();                         // Display encoder counts
}

void loop() {}                                // Nothing for main loop

void displayDistances()
{
  countsLeft = Arlo.readCountsLeft();         // Get left & right encoder counts
  countsRight = Arlo.readCountsRight();

  Serial.print("countsLeft = ");              // Display encoder measurements
  Serial.print(countsLeft, DEC);
  Serial.print(", countsRight = ");
  Serial.println(countsRight, DEC);
}

 

Serial Speed Control

If your robot is using sensors to navigate, maybe you just want your sketch to make the Arlo go forward until it finds an obstacle.  Instead of specifying a particular distance and setting aside a certain amount of time, your sketch can set each wheel speed and go until the sensors have detected a condition your sketch is looking for.   

Speed control is very similar to distance control.  The main difference is that the next sketch uses the ArloRobot object’s writeSpeeds function instead of writeCounts.  The writeSpeeds function sets the left and right wheel speeds in terms of counts per second.

This next example sketch just goes forward at 144 counts per second for 3 seconds.  Then, it turns left at 72 counts per second for 2 seconds.  After that, it retraces its steps by turning right at 72 counts per second for 2 seconds, and then backing up at 144 counts per second for 3 seconds.   

  • Set power like this: MAIN (on), MOTORS (off), BOE Shield (position-2)
  • Upload Serial Speed Maneuvers.ino.
  • Disregard the communication error message.
  • Turn all power off, unplug programming cable, and take to your Arlo navigation area.
  • Turn MAIN and MOTORS power on.
  • Set the BOE Shield power switch to 2.
  • Verify that the Arlo goes forward, and then backwards.
  • Try changing the left = 200  : right = 200      to     left = 150  : right = 50.
  • Change the        left = -200 : right = -200     to     left = -150 : right = -50.
/*
Arlo-Speed-Maneuvers
Examples that use ArloRobot library to make the arlo travel in certain
speeds for certain amounts of time.
*/

#include <ArloRobot.h>                        // Include Arlo library
#include <SoftwareSerial.h>                   // Include SoftwareSerial library

// Arlo and serial objects required
ArloRobot Arlo;                               // Arlo object
SoftwareSerial ArloSerial(12, 13);            // Serial in I/O 12, out I/O 13

int countsLeft, countsRight;                  // Encoder counting variables
void setup()                                  // Setup function
{
  tone(4, 3000, 2000);                        // Piezospeaker beep
  Serial.begin(9600);                         // Start terminal serial port
  Serial.println("Sketch running...");        // Display starting message
 
  ArloSerial.begin(19200);                    // Start DHB-10 serial com
  Arlo.begin(ArloSerial);                     // Pass to Arlo object

  Arlo.clearCounts();                         // Clear encoder counts

  Arlo.writeSpeeds(144, 144);                 // Go forward 144 counts/sec
  delay(3000);                                // for three seconds
  Arlo.writeSpeeds(0, 0);                     // Stop
  delay(1000);                                // for one second
  displayDistances();                         // Display encoder counts

  Arlo.writeSpeeds(-72, 72);                  // Rotate seft 72 counts/sec
  delay(2000);                                // for two seconds
  Arlo.writeSpeeds(0, 0);                     // Stop
  delay(1000);                                // ...for one second
  displayDistances();                         // Display encoder counts

  Arlo.writeSpeeds(72, -72);                  // Rotate right counts/sec
  delay(2000);                                // for two seconds
  Arlo.writeSpeeds(0, 0);                     // Stop
  delay(1000);                                // for one second
  displayDistances();                         // Display encoder counts

  Arlo.writeSpeeds(-144, -144);               // Go backward 144 counts/sec
  delay(3000);                                // for three seconds
  Arlo.writeSpeeds(0, 0);                     // Stop
  delay(1000);                                // for one second
  displayDistances();                         // Display encoder counts
}

void loop() {}                                // Nothing for main loop

void displayDistances()
{
  countsLeft = Arlo.readCountsLeft();         // Get left & right encoder counts
  countsRight = Arlo.readCountsRight();

  Serial.print("countsLeft = ");              // Display encoder measurements
  Serial.print(countsLeft, DEC);
  Serial.print(", countsRight = ");
  Serial.println(countsRight, DEC);
}

Printer-friendly version
Control BOE Shield Arlo with the Terminal
Prev
Connect & Test BOE Shield + Arlo Ping))) Sensors
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

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

© 2026 Parallax Learn • Built with GeneratePress