What is the SG90?
The SG90 is a very small hobby servo, about 9 grams, built from a brushed DC motor, a plastic gear train, a potentiometer on the output shaft and a small control board. You do not drive the motor directly. You send a short pulse every 20 ms, the electronics compare the pulse width with the shaft position reported by the potentiometer, and the motor runs until the two agree. That makes it the standard first actuator for anything that needs to move to a position and stay there: a camera tilt, a door latch, a flap on a model plane, a robot arm joint, a dispenser gate or a pointer on a gauge.
Specifications
- Type
- Positional hobby servo, brushed motor, plastic gears
- Weight
- about 9 g without horn and screws
- Body size
- about 23 x 12 x 29 mm including mounting tabs
- Operating voltage
- 4.8 V to 6 V, nominal 5 V
- Control signal
- Positive pulse, about 50 Hz repetition
- Pulse range
- about 500 us to 2400 us on many units; 1000 us to 2000 us is the safe common range
- Neutral position
- about 1500 us
- Travel
- roughly 180 degrees, varies with pulse range and unit
- Stall torque
- about 1.8 kgf-cm at 4.8 V (about 0.18 N-m)
- Speed
- about 0.1 s per 60 degrees with no load
- Idle current
- a few mA to about 10 mA when holding still
- Moving and stall current
- roughly 100 mA to 250 mA moving, 600 mA or more at stall
- Connector
- 3-pin, 0.1 inch pitch female header, brown / red / orange
Figures are typical of the Tower Pro SG90 data most sellers copy. The part is made by many factories, and torque, speed, pulse limits and current differ between batches, so treat them as ranges and test your own unit.
Pinout
| Wire | Name | Connect to |
|---|---|---|
| Brown | Ground | Controller ground and supply ground |
| Red | V+ | 4.8 V to 6 V supply; 5 V is the usual choice |
| Orange | Signal | A PWM-capable or timer-capable GPIO |
Pins on the 3-pin connector, in the order ground, power, signal. Some clones use black for ground and yellow or white for signal.
Wiring & code
Setting up SG90 with Arduino Uno
Library
Servo by Arduino
Bundled with the Arduino IDE
The SG90 is a 9-gram hobby servo: a small DC motor, a gearbox and a position-control circuit in one case. You don't drive the motor directly. You send a pulse every 20 ms, and its width sets the angle: about 0.5 ms for 0°, 1.5 ms for 90° and 2.4 ms for 180° on most SG90s. This guide wires one to an Arduino Uno, sweeps it, then makes it follow a potentiometer.
Wiring
| Component pin | Arduino Uno pin | Note |
|---|---|---|
| Brown (GND) | GND | Shared with any external servo supply |
| Red (V+) | 5V | 4.8–6 V. One SG90 is fine from USB; more need their own supply |
| Orange (signal) | D9 | Any digital pin; Servo.h then disables PWM on D9 and D10 |
Warning
Power is the usual problem. An SG90 draws about 100–250 mA while moving and up to about 650 mA when stalled or starting. That spike can drop the board's 5 V rail and reset it. Put a 470 µF capacitor across the servo's 5 V and GND, and for two or more servos use a separate 5 V supply (a 4×AA pack or a 5 V 2 A adapter) with its GND joined to the board's GND.
Sweep from 0° to 180°
/*
SG90 sweep on an Arduino Uno
Brown -> GND, red -> 5V, orange -> D9
*/
#include <Servo.h>
Servo servo;
void setup() {
servo.attach(9); // any digital pin works; Servo.h disables PWM on D9 and D10
}
void loop() {
for (int angle = 0; angle <= 180; angle += 2) { servo.write(angle); delay(15); }
delay(500);
for (int angle = 180; angle >= 0; angle -= 2) { servo.write(angle); delay(15); }
delay(500);
}Why the 500 and 2400. Servo libraries map 0–180° onto a pulse range. Many SG90s only reach their full travel with about 500–2400 µs, wider than Servo.h's 544–2400 µs default. If yours buzzes or strains at either end, it is pressing on its end stop: narrow the range (try 600–2300) or limit the angles you use. Moving in 2° steps with a short delay gives a smooth motion; a single write(180) makes the servo jump at full speed.
Follow a potentiometer
Add a 10 kΩ potentiometer: its two ends to 5V and GND, the middle pin (wiper) to A0. The sketch reads the knob and turns it into an angle. It only writes when the angle changes by more than 1°, so noise on the analog reading doesn't make the servo twitch.
/*
SG90 follows a potentiometer on an Arduino Uno
Servo: brown -> GND, red -> 5V, orange -> D9
Potentiometer: ends to 5V and GND, wiper -> A0
*/
#include <Servo.h>
Servo servo;
int lastAngle = -1;
void setup() {
Serial.begin(9600);
servo.attach(9, 500, 2400); // widen the default 544-2400 us range to reach the full 0-180°
}
void loop() {
int angle = map(analogRead(A0), 0, 1023, 0, 180);
if (abs(angle - lastAngle) > 1) { // ignore 1° jitter so the servo doesn't buzz
servo.write(angle);
Serial.println(angle);
lastAngle = angle;
}
delay(20);
}Try it in the simulator
This is the knob circuit with the sketch above. Press Run, then turn the potentiometer from its Settings: the servo horn follows and the Serial Monitor prints the angle.
Try this circuit in the SolderHub Simulator
Run this exact circuit in your browserReady-wired, code loadedConfirm simulator behavior against the real wiring and the sensor datasheet before connecting hardware.
Troubleshooting
| Symptom | Fix |
|---|---|
| Board resets or USB disconnects when the servo moves | Supply dip: add a 470 µF capacitor across the servo supply, or power the servo separately with GND shared |
| Servo jitters while still | Noisy signal or supply: shorten the wires, add the capacitor, and ignore small changes in the reading as the knob sketch does |
| Buzzes and gets warm at 0° or 180° | It is pushing on its end stop: narrow the pulse range or the angles |
| Doesn't move at all | Check the brown/red/orange order and the shared GND. A servo powered from 3.3 V may not move |
analogWrite() on D10 stops working | Servo.h uses Timer1, which disables PWM on D9 and D10 even when only one servo is attached |









