The SG90 is a popular micro servo motor ideal for lightweight and precision control applications like robotics, RC models, and DIY projects. With its compact size and easy interface with Arduino, it’s an excellent choice for beginners.
In this guide, we’ll show you how to wire up the SG90 servo motor to an Arduino Uno and write a simple sketch to control its movement.
What is the SG90 Servo Motor?
- Type: Analog Micro Servo
- Rotation Range: Approximately 0° to 180°
- Voltage Range: 4.8V – 6V
- Control Signal: PWM (Pulse Width Modulation)
What You’ll Need
- SG90 Servo Motor
- Arduino Uno R3
- Breadboard and jumper wires
- External power supply (optional, for stable operation)
- Arduino IDE
Wiring the SG90 Servo to Arduino
- Orange wire (Signal) → Arduino pin 9
- Red wire (VCC) → 5V (use external 5V if motor jitters)
- Brown wire (GND) → GND
Tip: If your servo motor draws too much current from the Arduino, use an external 5V power source and connect all grounds together.
Arduino Code to Control SG90
#include <Servo.h>
Servo myservo; // Create servo object
void setup() {
myservo.attach(9); // Attach to pin 9
}void loop() {
myservo.write(0); // Move to 0 degrees
delay(1000);
myservo.write(90); // Move to 90 degrees
delay(1000);
myservo.write(180); // Move to 180 degrees
delay(1000);
}
This code cycles the servo through three positions with one-second intervals.
Common Applications of the SG90
- Mini robotic arms
- Pan-tilt camera mounts
- Light control gates or flaps
- Smart locks or mechanisms
Conclusion
The SG90 is a reliable and affordable servo motor that’s perfect for learning how to control motion in electronics projects. With only three connections and simple code, you can quickly add movement to your Arduino creations.
Browse servo motors, sensors, and more at Rdxlectronics.com and get building today!