Servos
The motor that knows exactly where it is.
In 10 seconds
- • A servo moves to an exact angle, usually 0–180°.
- • Use the Servo library: attach() then write(angle).
- • Three wires: power, ground, signal.
A servo looks like a small plastic box with three wires and a little plastic arm sticking out of the top. Inside there is a motor, a set of gears and — this is the clever bit — a sensor that constantly reports the position of the output shaft. That feedback is what makes a servo different from every other motor: you do not tell it to spin, you tell it where to be.
Angles, not speed
Write myServo.write(0) and the arm swings all the way to one side. Write myServo.write(180) and it swings to the other. Write 90 and it sits neatly in the middle. If you push against the arm, the servo notices and pushes back to hold its position. This makes servos ideal for anything that needs to point, lift, steer or open: robot arms, radar scanners, little doors, camera mounts.
Most hobby servos, like the popular blue SG90, cover about 180 degrees. Continuous rotation servos are different animals — for those, the number controls speed and direction instead of angle.
The three wires
- Brown or black — ground, goes to GND.
- Red — power, 5 volts.
- Orange or yellow — signal, goes to any digital pin.
The signal wire carries a stream of tiny pulses, one every 20 milliseconds. The length of each pulse — between roughly 1 and 2 milliseconds — is what tells the servo which angle to hold. You never have to generate those pulses yourself, because the Servo library does it in the background. That is why the very first line of any servo sketch is #include <Servo.h>.
Power is the usual problem
One small servo moving gently is fine on the Arduino's 5V pin. Two or three servos moving at the same time, or one servo lifting something heavy, will pull far more current than the board can supply. The symptom is unmistakable: the servo jitters, the board resets, and your program starts again from the top. The cure is a separate 5V supply or battery pack for the servos, with its ground joined to the Arduino's ground.
Tips that save frustration
- Centre before assembling. Send the servo to 90 degrees, then attach the arm. Otherwise you will discover half your range is unusable.
- Move in steps. Jumping from 0 to 180 in one instruction is violent. Step a few degrees at a time with a short delay for smooth, realistic motion.
- Respect the limits. Forcing a servo past its mechanical end grinds the gears. Use software limits like 15 to 165 to stay safely inside.
- Listen. A servo that hums constantly while holding still is straining. Reduce the load or reposition the mechanism.
Quick quiz: Servos
3 questions to check it stuck.
Next lesson
🧩 Breadboards
Ready to try it for real?
Reading is good. Wiring is better. Pick a project and put this to work.
Explore projects