The robot uses two continuous rotation servos to move. These motors are a bit different than normal servos. See the Adafruit Motor Selection Guide on continuous servos for a great explanation for how they work.

The two servos we are using are rotated 180 degrees to each other (back to back) so one side will be running opposite the other. For example to go forward, run one servo forward, the other in reverse.

Using the Servo.write function, a setting of 180 is full forward, 0 is full reverse. 

The value for no motion would usually be 90 degrees but each servo might be a bit different. We need to do a bit of testing to find the actual angle for a stop value for the servos you get.

The program below uses the Circuit Playground to find the values for two Servos connected back to back. If the slide switch is on "+", the right motor is calibrated, "-" for the left motor. The two pushbuttons adjust the right motor by 0.1 degree (left minus, right plus). The angle is printed out on the Arduino serial monitor.

Use the circuit shown on the page "Use Circuit Playground" and the program below.

Download: file
// Circuit Playground Robot - Continuous Servo zero/no movement calibration program
// Mike Barela for Adafruit Industries   September, 2016

#include <Adafruit_CircuitPlayground.h>
#include <Servo.h>

Servo servoLeft;              // Define left servo
Servo servoRight;             // Define right servo
float speedAngleLeft = 90.0;  // Assume 90 degrees as a start
float speedAngleRight = 90.0;

void setup() { 
  servoLeft.attach(12);         // Set left servo to digital pin 12
  servoRight.attach(6);         // Set right servo to digital pin 6
  CircuitPlayground.begin();    // initialize the Circuit Playground library
  Serial.begin(9600);           // to output servo angle values
  Serial.println("Robot Continuous Servo Zero Movement Calibration");
} 

void loop() {                     // Loop through motion tests
  Serial.print("Speed Left = ");    Serial.print(speedAngleLeft); 
  Serial.print(", Speed Right = "); Serial.println(speedAngleRight);
  if(CircuitPlayground.slideSwitch()) {  // + = Calibrate Right, - = Calibrate Left
    if( CircuitPlayground.rightButton() ) {
      speedAngleRight += 0.1;
    }
    if( CircuitPlayground.leftButton() ) {
      speedAngleRight -= 0.1;
    }
  }
  else {
    if( CircuitPlayground.rightButton() ) {
      speedAngleLeft += 0.1;
    }
    if( CircuitPlayground.leftButton() ) {
      speedAngleLeft -= 0.1;
    }
  }
  servoLeft.write(speedAngleLeft);
  servoRight.write(speedAngleRight);
  delay(50);
}

To use the program, upload it to your Circuit Playground with the right servo control wire connected to Pin #6 and the left servo control motor connected to Pin #12.

When you power on the project, both wheels will probably turn slowly. Maddening that they do, as at an angle of 90 degrees we'd think they should be stopped. But we'll fix that.

Move the slide switch to + and open the Arduino IDE serial monitor to view the right motor angles. Press the Circuit Playground push buttons to increment or decrement the angle given to the right servo. The switches are not debounced so the values might be a bit jumpy. Eventually the motor will stop at a certain value displayed on the serial monitor. Note that value for right.

Move the slide switch to - and do the same angle adjustment for the left motor. Record the left value which results in no movement. For my two servos, the angles were 96.2 for the left servo, 95.3 for the right.

You can hard code these into the main robot program.  If you leave the values I found instead of using your own, you'll probably still have slowly turning wheels at a stop. All continuous servos are a bit different.

This guide was first published on Oct 12, 2016. It was last updated on Oct 12, 2016.

This page (Continuous Rotation Servos) was last updated on Nov 24, 2020.