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.
Community videos. Tishvi is not affiliated with creators.
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.
Arduino 5V pin = perfect
Full sweep in ~0.5 seconds
Any Arduino PWM pin (~)
Tiny enough for any project
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.
Wiring to Arduino UNO R3
3 wires total — takes under 2 minutes.
| SG90 Wire | Colour | Connect to Arduino | Why |
|---|---|---|---|
| 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 |
Basic Sweep Sketch
Make the servo sweep 0° → 180° → 0° continuously. Verify everything is working.
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.
Open Arduino IDE and paste this sketch
// 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); } }
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.
delay(10) value. delay(5) = twice as fast. To add a pause at each end, add delay(500); after each for-loop.Control to an Exact Angle
Point the servo to a specific position and hold it there — useful for locks, valves, camera mounts.
// 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 }
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
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.
.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).Next Steps
What to build with your servo next.
HC-SR04 Distance Sensor
Make your servo turn automatically when an object gets close — combine these two modules for a classic obstacle-avoidance build.
IR Obstacle Sensor
Use an IR sensor to trigger the servo when an obstacle is detected — great for automatic gates, barriers, and robot arms.
Arduino Project Hub
Hundreds of servo projects — robotic arms, pan-tilt cameras, automatic blinds, and more.