4DVolt

SG90 servo motor: pinout and wiring

The SG90 servo turns its shaft to an angle between 0° and 180° according to the width of a pulse. See the wire colors, how to connect it to Arduino, the Servo library code and try the angle in the simulator.

SG90 micro servo motor seen from above
SG90 servo

Specifications

Type
Position micro servo, 180°
Supply
4.8 V to 6 V
Control signal
50 Hz PWM (20 ms frame), 3.3 V or 5 V level
Pulse
≈ 0.5 ms (0°) to ≈ 2.4 ms (180°)
Torque
≈ 1.8 kg·cm at 4.8 V
Speed
≈ 0.1 s per 60°
Current
≈ 10 mA idle, up to ≈ 650 mA stalled
Weight
≈ 9 g

Pinout

The SG90 connector has three wires. Colors vary a little between makers, but the position is always the same: the dark wire is ground and the middle one is the supply.

SG90 (3 wires)

1 GND Ground (brown or black wire)
2 VCC Supply, 5 V (red wire)
3 SIG PWM signal (orange or yellow wire)

SG90 servo simulator

Move the angle and see the pulse width sent on the signal wire and the shaft position.

Pulse width
Duty of the 20 ms frame
Command

The servo measures the width of the pulse that arrives every 20 ms and moves the shaft to the matching angle. Wider pulse, larger angle.

How to wire it

Connect the brown wire to GND, the red to 5 V and the orange to a digital pin, such as D9 on the Arduino Uno. The Servo library works on any digital pin.

For a single servo making light movements, the Arduino 5 V is enough. With a load on the shaft or several servos, use an external 5 V supply and join its ground to the Arduino ground.

The angle comes from the width of the pulse repeated every 20 ms: about 0.5 ms puts the shaft at 0°, 1.5 ms at the center and 2.4 ms at 180°. The Servo library does this math from the angle.

Place a 100 µF to 470 µF electrolytic capacitor between 5 V and GND near the servo to absorb the current spikes when it starts moving.

Do not force the shaft by hand while the servo is powered, and do not ask for angles beyond its travel: the motor stalls, heats up and can strip the gears.

Example code (Arduino)

Sketch that sweeps the servo from 0° to 180° and back using the Servo library.

#include <Servo.h>

Servo servo;

void setup() {
  servo.attach(9);
}

void loop() {
  for (int a = 0; a <= 180; a += 2) {
    servo.write(a);
    delay(15);
  }
  for (int a = 180; a >= 0; a -= 2) {
    servo.write(a);
    delay(15);
  }
}

Common mistakes

  • Powering both the servo and the Arduino from the computer USB alone: the current spike resets the board. Use an external supply.
  • Forgetting to join the grounds when the servo supply is separate: the PWM signal has no reference and the servo jitters.
  • Asking for exactly 0° and 180° and leaving the servo pushing against the stop: use 10° to 170° if the shaft is binding.
  • Using pin 9 or 10 and expecting analogWrite PWM at the same time: the Servo library uses timer 1 and disables PWM on those pins on the Uno.
  • Confusing the 180° SG90 with a continuous rotation servo: a continuous one spins endlessly and the angle becomes speed.

Always check the manufacturer's datasheet for your exact model: pin order can vary between modules.

Frequently asked questions

How do I connect the SG90 servo to Arduino?

Brown to GND, red to 5 V and orange to a digital pin such as D9. In code use the Servo library with attach and write.

What are the SG90 wire colors?

Brown (or black) is ground, red is the supply and orange (or yellow) is the signal.

Does the SG90 work with ESP32?

Yes. Power the servo from 5 V and use an ESP32 output pin for the signal, which the servo recognizes at 3.3 V. Use the ESP32Servo library.

What is the SG90 pulse width?

From about 0.5 ms (0°) to 2.4 ms (180°), repeated every 20 ms. The Servo library uses 544 µs to 2400 µs.

Other components