SG90 Servo Motor with Arduino: Complete Beginner Guide (2026)
The SG90 Micro Servo Motor is one of the most popular servo motors for Arduino projects. Whether you're building a robotic arm, a pan-tilt camera, or a smart automation system, learning how to control a servo is an essential skill.
In this guide, you'll learn:
- What the SG90 servo motor is
- How it works
- Pin configuration
- Arduino wiring
- Arduino code
- Troubleshooting
- Practical applications
What Is an SG90 Servo Motor?
The SG90 is a lightweight 9g micro servo capable of rotating approximately 180°. Unlike a standard DC motor, it can move to a precise angle and hold that position using an internal feedback mechanism.
Inside the servo are:
- DC motor
- Plastic gear train
- Position feedback potentiometer
- Internal controller
Because of its simplicity and affordability, it's widely used in:
- Arduino projects
- Robotics
- DIY automation
- RC vehicles
- Camera pan-tilt systems
- Educational STEM projects
SG90 Specifications
| Feature | Value |
|---|---|
| Voltage | 4.8–6V |
| Recommended Voltage | 5V |
| Rotation | ~180° |
| Weight | 9g |
| Torque | ~1.8 kg·cm |
| Control | Servo Pulse |
Pinout
The SG90 has three wires.
| Color | Function |
|---|---|
| Brown | GND |
| Red | +5V |
| Orange | Signal |
Arduino Wiring
| Arduino | SG90 |
|---|---|
| 5V | Red |
| GND | Brown |
| D9 | Orange |
For one unloaded servo, Arduino 5V is usually enough.
For multiple servos or higher loads, use an external regulated 5V supply.
Real Hardware Connection
Before uploading the sketch:
- Verify wiring
- Ensure correct polarity
- Check jumper connections
- Make sure the servo horn moves freely ## Arduino Code
#include <Servo.h>
Servo myServo;
void setup() {
myServo.attach(9);
}
void loop() {
myServo.write(0);
delay(1000);
myServo.write(90);
delay(1000);
myServo.write(180);
delay(1000);
}
This sketch rotates the servo between 0°, 90°, and 180° continuously.
Servo Rotation
The Arduino converts angle values into servo control pulses.
| Command | Position |
|---|---|
| write(0) | 0° |
| write(90) | 90° |
| write(180) | 180° |
Troubleshooting
If the servo doesn't move:
- Check the wiring.
- Verify the power supply.
- Confirm that the signal wire is connected to pin 9.
If the Arduino keeps restarting:
- Use an external 5V power supply.
- Connect the external power supply ground to Arduino GND.
If the servo jitters:
- Improve the power supply.
- Reduce electrical noise.
- Shorten jumper wires.
Applications
The SG90 is commonly used in:
- Robotic arms
- Robot cars
- Smart door locks
- Pan-tilt systems
- RC aircraft
- DIY automation
- Sensor positioning
Conclusion
The SG90 Micro Servo Motor is one of the best components for beginners learning Arduino and robotics.
Once you understand servo control, you'll be ready to build more advanced projects such as robotic arms, camera gimbals, autonomous robots, and IoT automation systems.
Learn More
If you found this guide useful, leave a ❤️ on DEV.to and follow for more Arduino, ESP32, Raspberry Pi, robotics, and embedded systems tutorials.







Top comments (0)