How to connect an SG90 servo to Arduino
Signal on D9, separate 5 V supply, common ground.
Wiring diagram
Open in the builderStep-by-step assembly
4 steps- 4 wires in order: ground, power, signals.Click a wire on the diagram or a table row to open its step.The ← → arrow keys flip through the steps.
- Step 1: GND of the servo to GND of the USB-C jack
- Step 2: GND of the USB-C jack to GND of the board
- Step 3: VCC of the servo to VBUS of the USB-C jack5 V. The servo draws up to 650 mA, the pin supplies about 1500 mA.
- Step 4: PWM of the servo to D9 of the board
- Done: 4 wires in place.Check against the connection table below.
Connections
| Step | From | To | Color |
|---|---|---|---|
| 1 | USB-C 6P GND | SG90 GND | black |
| 2 | Arduino Uno GND | USB-C 6P GND | black |
| 3 | USB-C 6P VBUS | SG90 VCC | red |
| 4 | Arduino Uno ~9 | SG90 PWM | PWM, lime |
Power and wiring check
- The schematic check, the same as in the builder, found no errors: pin voltages match, ground is common, buses are fully connected.
- SG90 draws up to 650 mA (about 200 typically) from the VBUS pin of USB-C 6P, the pin supplies about 1500 mA: USB-C with 5.1 kΩ resistors: charger up to 1.5–3 A, computer port 500–900 mA.
Current of the whole circuit and how long it runs on a battery: power budget. Where to plug what: breadboard layout.
Example code
Arduino IDE, Servo 1.2 (bundled with the Arduino IDE).
#include <Servo.h>
Servo servo;
void setup() {
servo.attach(9);
}
void loop() {
servo.write(0);
delay(1000);
servo.write(90);
delay(1000);
servo.write(180);
delay(1000);
}
Part pinouts
Next steps for this circuit
How it is connected
The SG90 signal (orange wire) goes to D9: the Servo library outputs a 1-2 ms pulse every 20 ms. Power (red) and ground (brown) in the schematic come from a separate USB-C board with a 5 V supply, and its ground is connected to the Arduino's GND. Without a common ground the servo twitches or stands still.
An SG90 draws 100-250 mA while moving and up to 650 mA at stall. The Uno's 5V pin from USB gives about 400 mA, so when the servo is powered from it the circuit check raises a warning: at stall the board resets, and the USB port may disconnect.
FAQ
- Why does the servo twitch and the Arduino reset?
- At start and at stall the servo draws more than the 5V pin can give, and the voltage sags. Power the servo separately from a 5 V source rated 1-2 A and connect the grounds.
- Can I connect an SG90 to an ESP32?
- Yes. An SG90 usually understands a 3.3 V signal, power it with 5 V separately, and tie the grounds together. The library for the ESP32 is ESP32Servo.
- How many servos can an Arduino handle?
- There are enough signal pins for 12 servos on an Uno with the Servo library, but they must be powered from a separate supply. For 16 servos, a PCA9685 board over I2C is more convenient.