Activity 5: Centering the Servos
In this activity, you will run a sketch that sends the “stay-still” signal to the servos. You will then use a screwdriver to adjust the servos so that they actually stay still. This is called centering the servos. After the adjustment, you will run test sketches that will turn the servos clockwise and counterclockwise at various speeds.
Tool Required
You’ll need a Phillips #1 point screwdriver with a 1/8″ (3.18 mm) or smaller shaft.
Sending the Center Signals
If a servo has not yet been centered, it may turn, vibrate, or make a humming noise when it receives the “stay-still” signal.
- Reconnect your programming cable, and re-run LeftServoStayStill.
- Set the BOE Shield’s Power switch to 2, to provide power to the servos.
- Use a screwdriver to gently adjust the potentiometer in the servo as shown in Figure 2‑26. Don’t push too hard! Adjust the potentiometer slightly until you find the setting that makes the servo stop turning, humming or vibrating.
- Verify that the pin 13 LED signal monitor circuit is showing activity. It should glow like it did when you ran LeftServoStayStill the first time.
What’s a Potentiometer?
A potentiometer is kind of like an adjustable resistor with a moving part, such as a knob or a sliding bar, for setting the resistance. The Parallax continuous rotation servo’s potentiometer is a recessed knob that can be adjusted with a small Phillips screwdriver tip. Learn more about potentiometers in What’s a Microcontroller? and Basic Analog and Digital at www.parallax.com.
Your Turn – Center the Servo Connected to Pin 12
- Repeat the process for the pin 12 servo using the sketch RightServoStayStill.
/* Robotics with the BOE Shield – RightServoStayStill Transmit the center or stay still signal on pin 12 for center adjustment. */ #include <Servo.h> // Include servo library Servo servoRight; // Declare right servo void setup() // Built-in initialization block { servoRight.attach(12); // Attach right signal to pin 12 servoRight.writeMicroseconds(1500); // 1.5 ms stay still signal } void loop() // Main loop auto-repeats { // Empty, nothing needs repeating }