Servos suit a wide range of projects, from a single-servo eye to a multi-joint robot arm. This article lists project ideas by difficulty, explains how to power servos safely, and shows how to reverse a servo’s direction. For the travel range of different servo types, see how much a servo motor can turn.
Beginner projects (one or two servos)
- Moving eye: a servo tilts an eyeball or pointer. Code sets random or scripted moves. A good first project for learning angle control.
- Pan-tilt mount: two servos aim a camera or sensor. Teaches control of two axes.
- Light-following flower or sensor: a light sensor sets the angle. Teaches reading an analog input and mapping it to an angle.
- Button pusher or latch: a servo presses a switch or moves a latch when triggered. Teaches triggering, and why you should limit the force.
Intermediate projects (several servos)
- Servo tester: a box with potentiometers sets each servo’s angle. Useful for checking servos before a build.
- Mechanical 7-segment display: servos move segments to form digits.
- Gimbal: servos stabilised by a motion sensor. Needs a control loop, so start simple.
- Automatic wiper or door: a sensor triggers the movement. Add end limits in code.
Advanced robots and machines
- Robot arm: several joints, often with metal-gear servos. Plan the power budget and joint limits carefully. Keep fingers clear of pinch points.
- Walking robot: many servos moving in coordination. Plan for high current draw.
- Pen plotter: an X-Y gantry with a servo that lifts the pen.
Types of servo motors
- Positional (standard hobby) servos: move to an angle, usually about 180 degrees. This is the most common type.
- Continuous-rotation servos: spin in either direction, with speed set by the pulse. They do not hold an angle.
- Multi-turn servos: turn a few full rotations with geared feedback. Less common.
Industrial servo systems use AC or DC motors with encoders and drives. They are a different class of product from hobby servos. A simple positional servo can be built from a DC motor, a potentiometer and a control loop, but a ready-made servo is usually cheaper and easier to use.
Using servos with Arduino
Arduino boards can drive servos with the built-in Servo library. Connect the signal wire to a PWM-capable pin, and use write() to set an angle from 0 to 180.
#include <Servo.h>
Servo arm;
void setup() {
arm.attach(9); // signal wire on pin 9
}
void loop() {
arm.write(90); // centre position
}
Power: keep servo current off the Arduino
Servos draw current in bursts when they move, and much more when they stall against a load. Several servos on the Arduino’s 5 V pin can reset the board or brown out the supply.
- Use a separate 5 V or 6 V supply rated for the total current of all servos, including stall current.
- Connect the supply’s ground to the Arduino ground. A shared ground is needed for the signal to make sense.
- A capacitor of 100 µF to 470 µF across the servo supply can smooth the current spikes.
How to reverse a servo
Standard positional servos:
- Do not swap the power wires to reverse the servo. Reversing the supply polarity can damage it. Only the signal wire changes what the servo does.
- Reverse the angle in code. For example,
arm.write(180 - angle);maps 0 to 180 and 180 to 0. - Alternatively, remove the horn, rotate it 180 degrees, and refit it. Then match the code to the new orientation.
Continuous-rotation servos:
The pulse width sets the speed and direction, not an angle. On many models, a pulse near 1.5 ms stops the motor. Shorter pulses turn it one way, and longer pulses turn it the other way. Use the trim pot, if the model has one, to get a clean stop.
#include <Servo.h>
Servo wheel;
void setup() {
wheel.attach(9);
wheel.writeMicroseconds(1500); // stop on many models
}
void loop() {
wheel.writeMicroseconds(1300); // one direction
delay(2000);
wheel.writeMicroseconds(1500); // stop
delay(1000);
wheel.writeMicroseconds(1700); // the other direction
delay(2000);
wheel.writeMicroseconds(1500);
delay(1000);
}
Pulse values vary between models. Test in small steps.
Build checklist
- Torque with margin: choose a servo whose rated torque comfortably exceeds the load at the lever’s distance. Ratings are often in kg·cm.
- Limits in code: set minimum and maximum angles that match the mechanical travel, so the servo does not hit its stops.
- Secure mounting: use the right horn and secure the linkages.
- Cable clearance: keep wires away from gears and moving joints.
- Repair: a worn or damaged hobby servo is usually cheaper to replace than to repair.
Stalled servos heat up. If a servo is stuck, cut the power and find the cause before you restart it.