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: regulated power, ground, signal; check the exact servo datasheet.
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
Even one small servo can draw a large current when starting or stalled, so use a regulated 5V supply sized for the servo rather than assuming the Arduino's 5V pin is enough. Join the supply ground to Arduino GND. If a servo jitters, stalls, buzzes hard or gets hot, disconnect power and ask an adult to check the mechanism and supply.
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.
Code to go with this lesson
Next lesson
🧩 Breadboards
Ready to try it for real?
Pick a project and ask a parent, teacher, or trusted adult to check the parts and power before you build. Buying hardware is optional and at your own cost.
Explore projects