Skip to content

Actuators · Servo

SG90 Micro Servo Motor

The classic 9g micro servo — small, cheap, and perfect for any hobby mechanism.

Updated November 22, 2026 2 board guides
SG90 Micro Servo Motor

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.

Run the SG90 in your browser

Ready-wired circuit with code. No hardware, no install.

SG90 at a glance

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.

How a hobby servo works

Inside the case a small DC motor turns a train of reduction gears. The last gear drives the output shaft, and the same shaft turns a small potentiometer. The control board reads that potentiometer, reads your incoming pulse, and drives the motor forward or backward through an H-bridge until the shaft angle matches the pulse. This is a closed loop, so the servo resists being pushed away from its target and holds position without you doing anything in code.

The command is pulse-width coded rather than a plain PWM duty cycle. Every 20 ms (50 Hz) you send a high pulse, and its length in microseconds is the angle request. Around 1500 us is the middle, shorter pulses go toward one end and longer pulses toward the other. The repetition rate is not critical: most servos accept anything from about 40 Hz to 60 Hz, and the servo keeps pushing toward its target for as long as pulses keep arriving. If the pulses stop, many analog servos relax and can be turned by hand.

The SG90 is an analog-style servo. Its control loop has a dead band of several microseconds, so tiny changes in pulse width produce no movement, and the horn may hum or twitch slightly when it is loaded and trying to hold a position.

Pinout

WireNameConnect to
BrownGroundController ground and supply ground
RedV+4.8 V to 6 V supply; 5 V is the usual choice
OrangeSignalA 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.

SG90 pinout, drawn from the SolderHub Simulator part: what each pin does

Warning

Do not power a servo from a GPIO pin and do not assume the colours are universal. The wire next to the plain brown or black one is power, and the outermost wire in a different colour is signal. Plugging the connector in backwards puts supply voltage on the signal pin, which can damage a microcontroller input.

Power: the part most people get wrong

A servo does not draw a steady current. At rest it takes very little. When the shaft accelerates, or when the horn is blocked or loaded, current rises sharply, and a stalled SG90 can pull more than half an ampere. Those spikes last milliseconds, but they are enough to pull a weak supply down.

  • Arduino Uno. A single SG90 moving a light load is commonly run from the Uno 5 V pin when the board is powered over USB, but the USB port is shared with everything else. For two or more servos, or any real load, use a separate 5 V supply and tie its ground to the Arduino ground.
  • ESP32. The ESP32 5 V pin (VIN) is wired to USB power on most dev boards, so it works for a single SG90. If the board resets or Wi-Fi drops when the servo moves, that is a brownout from the current spike. Move the servo to its own 5 V supply and share ground.
  • Batteries. Four AA cells give about 4.8 V to 6 V and are within range. A single Li-ion cell is 3.0 V to 4.2 V, which is below the rated minimum, so the servo may be weak or jittery. Use a boost converter or a 5 V regulator.
  • Decoupling. A capacitor of 100 uF to 470 uF across the servo supply, placed near the servo connector, smooths the startup spike. Add a 100 nF ceramic capacitor beside it for high-frequency noise.

Never feed the servo more than 6 V unless your unit is explicitly rated for it. A 7.4 V two-cell LiPo can destroy the control board or overheat the motor.

Signal and logic level

The servo's signal input expects a pulse that rises above about 3 V. In practice most SG90 units read a 3.3 V logic signal from an ESP32 correctly even when the servo itself runs on 5 V, and this is the method used on the board page. If a particular unit behaves unreliably from 3.3 V, with random twitching or no response, a small level shifter or a transistor buffer on the signal line is a simple fix. The servo returns nothing on the signal wire, so a 5 V servo never sends 5 V into a 3.3 V pin and no protection is needed in that direction.

The pulse must have a common ground with the servo. If the servo has its own supply, join the grounds of the two supplies, otherwise the signal has no reference and the servo moves erratically.

Pulse width and angle

  • 500 us to 600 us

    Approximate position
    Near one end stop
    Notes
    Some units hit the mechanical stop before reaching this value; test carefully
  • 1000 us

    Approximate position
    About 0 degrees on many libraries
    Notes
    Common safe lower limit across servos
  • 1500 us

    Approximate position
    Centre, about 90 degrees
    Notes
    Use this as the first test pulse
  • 2000 us

    Approximate position
    About 180 degrees on many libraries
    Notes
    Common safe upper limit across servos
  • 2400 us to 2500 us

    Approximate position
    Near the other end stop
    Notes
    Pushing past the stop makes the servo buzz and draw high current

These are approximate and unit dependent. The Arduino Servo library defaults to 544 us to 2400 us, which is why a default sweep can drive some SG90 units hard into their end stops.

Calibrating the end points

The angle you write in code is only a mapping from degrees to pulse width, and the mapping is wrong for many servos. If your servo buzzes at 0 or 180 degrees, it is trying to push past its mechanical stop. The fix is to restrict the pulse range in the library call, for example attach with minimum 500 and maximum 2400 on Arduino, or use the ESP32Servo library and set the same limits. Start at 1000 us and 2000 us, then widen the range in steps of 50 us while listening for buzzing and feeling for heat.

Fit the horn after the servo has been driven to centre. If you mount the horn first, you can end up with a mechanism that cannot reach the full travel because the splines on the horn are in the wrong tooth. Moving the horn one spline tooth changes the offset by roughly 15 to 20 degrees, depending on the horn, and finer correction is done by changing the centre pulse in software.

The SG90 repeats its position within a few degrees but is not precise. Backlash in the plastic gears and the dead band mean you should not expect better than about one or two degrees of accuracy, and it varies with the load.

Common mistakes

  1. Powering a servo from a dev board pin that cannot supply the current. This causes resets, serial noise and sketches that restart each time the servo moves.
  2. Missing common ground. An external supply with no ground link to the microcontroller produces random motion.
  3. Writing to a position, then immediately writing another. A servo needs time to arrive. At 0.1 s per 60 degrees, a full sweep takes roughly 0.3 s to 0.5 s with a small load, and faster writes simply queue up and look jerky.
  4. Stalling the servo. Forcing the horn against a stop or a heavy load keeps the motor at stall current, which heats the motor and strips the plastic gears. Detach the servo or stop sending pulses when the mechanism does not need to hold.
  5. Using 5 V servo supply and 3.3 V logic without testing. Usually fine, but it is the first thing to check when a particular unit twitches.
  6. Mixing the library and a timer-using library. On a Uno, the Servo library uses Timer 1 and disables PWM on pins 9 and 10. On ESP32, make sure the PWM channel you choose is not already used by another feature.

Troubleshooting

  • Servo does nothing

    Likely cause
    No power, no common ground, or signal on the wrong pin
    What to try
    Check 5 V on the red wire, join grounds, confirm the GPIO number in code, test with a centre pulse of 1500 us
  • Board resets when the servo moves

    Likely cause
    Current spike browns out the supply
    What to try
    Use a separate 5 V supply, add a 100 uF to 470 uF capacitor across the servo power, share ground
  • Servo buzzes or hums at the ends of travel

    Likely cause
    Pulse range exceeds the mechanical limits
    What to try
    Narrow the minimum and maximum pulse, for example to 600 us and 2300 us, then widen carefully
  • Servo jitters at a fixed position

    Likely cause
    Noisy supply, unstable signal, or software timing jitter
    What to try
    Add a capacitor, shorten the signal wire, use a hardware PWM channel instead of bit-banging, power from a regulated supply
  • Servo is weak or slow

    Likely cause
    Supply sags below 4.8 V, or the load is too high
    What to try
    Measure the voltage at the servo while it moves; reduce the load or use a metal-gear servo such as the MG90S
  • Horn rotates freely and cannot hold position

    Likely cause
    Stripped plastic gears
    What to try
    Replace the servo; gears are not repairable in practice
  • Gets hot

    Likely cause
    Held against a stop or stalled for a long time
    What to try
    Cut power and fix the mechanical binding or the pulse range

Most servo faults come from power, ground or an over-wide pulse range.

SG90 compared with similar parts

The SG90 is the cheapest choice, and its limits are plastic gears and modest torque. When a project moves a real weight or runs all day, a different part is usually a better answer than gentle treatment of an SG90.

Alternatives

PartTorqueNotes
SG90about 1.8 kgf-cmPlastic gears, cheapest, fine for light flaps and camera tilt
MG90Sabout 2 kgf-cm to 2.2 kgf-cmSame footprint with metal gears; better for shock loads, slightly heavier
MG996Rabout 9 kgf-cm to 11 kgf-cmFull-size servo for arms and heavier loads; needs a proper supply with several amps of headroom
Continuous rotation micro servosimilar to SG90Same housing, but the pulse sets speed and direction rather than angle; no position feedback
28BYJ-48 stepper with ULN2003lowMany rotations and open-loop position; slower and bulkier, needs four control lines

Torque figures are typical datasheet values at about 4.8 V to 6 V and differ by manufacturer.

Project ideas

  • A pan-tilt camera mount with two SG90 servos driven from a joystick or from face-tracking software.
  • A small pet-food or pill dispenser that rotates a gate for a fixed time.
  • A model rail crossing barrier or turnout switch.
  • A radar-style sweep with an ultrasonic distance sensor mounted on the horn.
  • A robot hand where each finger is pulled by a servo and a line.
  • A coin sorter or ball launcher trigger that releases a latch on command.

For several servos at once, a PCA9685 16-channel PWM driver on I2C removes the timing load from the microcontroller and gives each servo steady pulses.

Ready to build? Pick your board for wiring and a working sketch:

Frequently asked questions

Can I power an SG90 from 3.3 V? It may twitch, but torque and speed are poor and many units will not hold position. The rated range is 4.8 V to 6 V, so use 5 V.

Does it really rotate 180 degrees? Often about 160 to 180 degrees with the library defaults, depending on the pulse range and the unit. Measure the actual travel with a protractor and calibrate.

Can I run it from a Raspberry Pi GPIO directly? The signal can come from a GPIO, but software PWM on a Pi is jittery. Use hardware PWM or a PCA9685 board, and power the servo from a separate 5 V supply.

Why does it sometimes move when I upload code? Pins can float or toggle during reset and bootloader activity, which produces random pulses. A 10 kOhm pull-down resistor on the signal line, or choosing a pin that is quiet at boot, helps.

How many SG90 servos can one Arduino run? The Servo library supports 12 on most Uno-class boards, and signals are not the limit. Power is: budget about 500 mA of headroom per servo that may move at once.

Can it rotate continuously? Not as supplied. A continuous-rotation version is sold separately, or the stop and potentiometer can be modified, which is fiddly and permanent.

References

  • Tower Pro SG90 datasheet, for the commonly quoted torque, speed and voltage figures; note that copies sold by other vendors may differ
  • Arduino Servo library reference, for attach, write and writeMicroseconds
  • ESP32Servo library on GitHub, the usual servo library for ESP32 boards
  • Adafruit PCA9685 16-channel servo driver guide, for driving many servos from I2C

Wiring & code

Board integration

Library

ESP32Servo by Kevin Harrington

Library Manager: search "ESP32Servo"

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 ESP32, sweeps it, then makes it follow a potentiometer.

On an ESP32 the usual Arduino Servo.h does not work: it is written for AVR timers. Use the ESP32Servo library, or the ESP32's own LEDC PWM as in the second sketch.

Wiring

Component pinESP32 pinNote
Brown (GND)GNDShared with any external servo supply
Red (V+)5V / VIN4.8–6 V. Never 3V3: the servo resets the board
Orange (signal)GPIO183.3 V pulses are enough for an SG90; avoid strapping pins 0, 2, 12 and 15
SG90 on an ESP32 in the SolderHub Simulator: brown to GND, red to 5V, orange to GPIO18, and a 10 kΩ potentiometer on GPIO34 (powered from 3V3) for the knob sketch

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. The ESP32's 5V/VIN pin is USB power passed through, so it has the same limit.

Install the library

In Tools → Manage Libraries, search for ESP32Servo and install the library by Kevin Harrington. It drives up to 16 servos from the ESP32's LEDC PWM hardware and keeps the familiar write(angle) interface.

Sweep from 0° to 180°

sketch.ino
/*
  SG90 sweep on an ESP32 with the ESP32Servo library
  Brown -> GND, red -> 5V (VIN), orange -> GPIO18
  Install "ESP32Servo" by Kevin Harrington from the Library Manager.
*/
#include <ESP32Servo.h>

Servo servo;
const int SERVO_PIN = 18;

void setup() {
  servo.setPeriodHertz(50);              // standard 50 Hz servo frame
  servo.attach(SERVO_PIN, 500, 2400);    // pulse width for 0° and 180°, in microseconds
}

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 ESP32Servo'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 3V3 and GND, the middle pin (wiper) to GPIO34. The sketch reads the knob and turns it into an angle. This version uses no library: ledcAttach() sets up a 50 Hz, 14-bit PWM on the pin and ledcWrite() sets the pulse width directly, which shows exactly what the servo receives. It needs Arduino-ESP32 core 3.x; the old ledcSetup()/ledcAttachPin() functions were removed.

sketch.ino
/*
  SG90 follows a potentiometer, using the ESP32's LEDC PWM directly (no library)
  Servo: brown -> GND, red -> 5V (VIN), orange -> GPIO18
  Potentiometer: ends to 3V3 and GND, wiper -> GPIO34
  Arduino-ESP32 core 3.x: ledcAttach() / ledcWrite() take the pin number.
*/
const int SERVO_PIN = 18;
const int POT_PIN = 34;
const int FREQ = 50;                     // 50 Hz = 20 ms frame
const int RES = 14;                      // 14-bit duty: 0..16383

void writeMicros(int us) {
  ledcWrite(SERVO_PIN, (uint32_t)us * ((1 << RES) - 1) / 20000);
}

void setup() {
  Serial.begin(115200);
  ledcAttach(SERVO_PIN, FREQ, RES);
}

void loop() {
  int raw = analogRead(POT_PIN);         // 0..4095
  int angle = map(raw, 0, 4095, 0, 180);
  writeMicros(map(angle, 0, 180, 500, 2400));
  Serial.println(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 loaded

Confirm simulator behavior against the real wiring and the sensor datasheet before connecting hardware.

Troubleshooting

SymptomFix
Board resets or USB disconnects when the servo movesSupply dip: add a 470 µF capacitor across the servo supply, or power the servo separately with GND shared
Servo jitters while stillNoisy 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 allCheck the brown/red/orange order and the shared GND. A servo powered from 3.3 V may not move
Servo.h compile error: "not supported on ESP32"Install ESP32Servo and include <ESP32Servo.h>
ledcSetup was not declaredArduino-ESP32 3.x removed it: use ledcAttach(pin, freq, resolution) and ledcWrite(pin, duty)

Step-by-step

Board guides