/ SG90 Servo Motor Guide
← All Guides Shop ↗
🌐 Translate:
⏱ 15 min 🔌 3 wires ✅ Beginner

SG90 Micro Servo Motor
Setup Guide

Control a servo motor with your Arduino UNO R3 — make it sweep back and forth, or point to a precise angle. No soldering needed. Takes about 15 minutes.

📺

Video walkthrough

Prefer to watch? These cover the same steps.

Arduino Servo Motor Tutorial — SG90
DroneBot Workshop · YouTube
▶ YouTube
SG90 Servo Control — Exact Angles
Paul McWhorter · YouTube
▶ YouTube

Community videos. Tishvi is not affiliated with creators.

1

What is the SG90 Servo?

Understand what you're working with before you wire anything up.

The SG90 is a lightweight micro servo motor. Unlike regular motors that spin continuously, a servo rotates to a specific angle (0° to 180°) and holds it there. You control the angle by sending it a PWM signal from your Arduino.

Operating Voltage
4.8V – 6V
Arduino 5V pin = perfect
🔄
Rotation Range
0° to 180°
Full sweep in ~0.5 seconds
📏
Signal Type
PWM, 50Hz
Any Arduino PWM pin (~)
🪶
Weight & Size
9g, 23×12×29mm
Tiny enough for any project
ℹ️
The SG90 comes with 3 plastic horn attachments (round, cross, single-arm). Snap any one onto the servo shaft. The horn position can be adjusted manually when the servo is unpowered.
2

What You Need

Everything required — most of this came in your Tishvi kit.

Tishvi Arduino UNO R3

Any variant (DIP or SMD). Must be already set up with Arduino IDE — see the UNO R3 Setup Guide first if you haven't done that yet.

SG90 Micro Servo Motor

The small plastic servo with 3 wires: Orange (signal), Red (power), Brown (ground). Included in Tishvi sensor kits.

3× Jumper Wires (Female-to-Male)

Female end connects to the servo's 3-pin connector. Male end plugs into Arduino headers. The servo connector is keyed — it only goes in one way.

USB-A to USB-B Cable

To connect Arduino to your computer for uploading code. The same cable used in the UNO R3 setup.

💡
No breadboard needed! The SG90's 3-pin connector plugs directly to Arduino via jumper wires. This is one of the simplest wiring setups you'll do.
3

Wiring to Arduino UNO R3

3 wires total — takes under 2 minutes.

ARDUINO UNO R3 ~9 5V GND Signal (Orange) Power (Red) Ground (Brown) SG90
SG90 WireColourConnect to ArduinoWhy
Signal ■ Orange Pin 9 (or any PWM pin marked ~) Carries the angle command from your sketch
Power ■ Red 5V pin Powers the servo motor. SG90 needs 4.8–6V
Ground ■ Brown (or Black) GND pin Completes the circuit
⚠️
PWM pin required for signal. On UNO R3, PWM pins are 3, 5, 6, 9, 10, 11 (marked with ~ on the board). Pin 9 is recommended. Do not use pins 0, 1, 2, 4, 7, 8, 12, 13 for servo signal — they won't work.
💡
Power note: A single SG90 draws up to 250mA. Arduino's 5V pin can supply up to ~500mA, so one servo is fine. For 3+ servos, use an external 5V power supply and share a common ground with Arduino.
4

Basic Sweep Sketch

Make the servo sweep 0° → 180° → 0° continuously. Verify everything is working.

1

The Servo library is built-in — no install needed

Arduino IDE includes the Servo.h library by default. You don't need to install anything extra from the Library Manager.

2

Open Arduino IDE and paste this sketch

servo_sweep.ino
// SG90 Servo — Basic Sweep
// Tishvi Docs: tishvi.com/docs
// Wiring: Orange → Pin 9 | Red → 5V | Brown → GND

#include <Servo.h>

Servo myServo;      // create a servo object

void setup() {
  myServo.attach(9);  // attach servo to pin 9
}

void loop() {
  // Sweep from 0° to 180°
  for (int angle = 0; angle <= 180; angle++) {
    myServo.write(angle);
    delay(10);          // 10ms per degree = ~1.8s full sweep
  }

  // Sweep back from 180° to 0°
  for (int angle = 180; angle >= 0; angle--) {
    myServo.write(angle);
    delay(10);
  }
}
3

Upload the sketch

Click Upload → (or Ctrl+U). The servo should start sweeping immediately after upload — you'll hear a quiet buzzing as it moves.

Servo sweeping back and forth = everything wired correctly. The full 0°→180° sweep takes about 1.8 seconds.
💡
To make it sweep faster, reduce the delay(10) value. delay(5) = twice as fast. To add a pause at each end, add delay(500); after each for-loop.
5

Control to an Exact Angle

Point the servo to a specific position and hold it there — useful for locks, valves, camera mounts.

servo_exact_angle.ino
// SG90 Servo — Exact Angle Control
// Change the angle values below to test positions

#include <Servo.h>

Servo myServo;

void setup() {
  myServo.attach(9);

  myServo.write(0);    // go to 0° (left end)
  delay(1000);

  myServo.write(90);   // go to 90° (centre)
  delay(1000);

  myServo.write(180);  // go to 180° (right end)
  delay(1000);

  myServo.write(90);   // return to centre and hold
}

void loop() {
  // Nothing — servo holds at 90° indefinitely
}
ℹ️
Key concept: myServo.write(angle) tells the servo to move to that angle. The servo will hold that position under load — it constantly fights to stay there. To release the hold (save power / stop buzzing), call myServo.detach().

🎛 Servo angle reference

90°
180°
← Full leftCentreFull right →
6

Troubleshooting

Not working? Check these first.

?

Servo doesn't move at all

Check that the signal wire goes to a PWM pin (marked ~ on the board). Pin 9 is safest. If using another pin, make sure it's in the PWM list: 3, 5, 6, 9, 10, 11. Also confirm red wire is in 5V not 3.3V.

?

Servo jitters or buzzes constantly

Normal for SG90 to hum slightly when holding position. Excessive jitter usually means the power supply is unstable — add a 100µF capacitor between 5V and GND, or power via USB hub rather than laptop port.

?

Servo moves but not to the right angle

SG90 physical travel may be slightly less than 180°. You can trim the range: use myServo.attach(9, 500, 2500); to set min/max pulse width (microseconds) for calibration.

?

Arduino resets when servo moves

The servo is drawing too much current from the USB port. Power the Arduino from a wall adapter (via USB) rather than a laptop port — laptops often limit USB current to 500mA.

?

Upload fails after wiring servo

The Servo library uses Pin 9 and 10 internally and can sometimes conflict. Unplug the servo while uploading, then replug after the upload completes.

Download Sample Sketch

Get a ready-to-upload .ino file for the SG90 servo sweep.

Download the complete sample sketch below — it includes wiring comments, a full 0°→180° sweep, and Serial Monitor output so you can see the angle in real time. No changes needed before uploading.

📄
sg90_sweep_sample.ino
Full sweep 0°→180°→0° · Serial Monitor output · Well-commented
⬇ Download .ino
💡
How to open: In Arduino IDE go to File → Open and select the downloaded .ino file, or drag it onto the IDE window. Make sure the Servo library is available (it ships built-in with Arduino IDE — no install needed).