Home Industry InsightServo
Looking for a suitable motor? Looking for a suitable motor?
Looking for a suitable motor?

Mastering the SG90 Servo Motor Pinout: A Comprehensive Guide for Beginners and Hobbyists

小编

Published2025-09-16

Understanding the SG90 Servo and Its Pinout

Introduction to the SG90 Servo Motor The SG90 servo motor is a staple in the world of DIY electronics, robotics, and automation. Known for its compact size, affordability, and ease of use, this micro servo is a favorite among hobbyists and professionals alike. But before you can harness its power, you need to understand its pinout—the key to unlocking its capabilities.

In this guide, we’ll break down the SG90 servo pinout, explain how to wire it to popular microcontrollers like Arduino, and explore its real-world applications. Whether you’re building a robot arm, a solar tracker, or a smart home gadget, mastering the SG90’s pinout is your first step toward success.

Anatomy of the SG90 Servo The SG90 servo consists of three primary components:

Motor: A small DC motor that drives the servo’s movement. Gearbox: Reduces the motor’s speed while increasing torque. Control Circuit: Processes input signals to position the servo accurately.

But the heart of any servo integration lies in its wiring—specifically, the three colored wires protruding from its cable.

Decoding the SG90 Pinout The SG90 servo has three wires, each with a distinct color and purpose:

Orange (or Yellow) Wire: Signal/PWM Input This wire carries the control signal from a microcontroller (e.g., Arduino or Raspberry Pi). The servo’s angle is determined by the pulse width of the signal (typically 1–2 ms). Red Wire: Power (VCC) Connects to a 4.8–6V power source. Avoid using the microcontroller’s 5V pin for multiple servos—use an external supply instead. Brown (or Black) Wire: Ground (GND) Completes the circuit by connecting to the ground of the power source and microcontroller.

Why the Pinout Matters Misconnecting these wires can lead to:

Servo malfunction (e.g., jitter, overheating). Damage to the microcontroller or power supply. Inaccurate positioning or complete failure.

Connecting the SG90 to an Arduino Let’s walk through a basic wiring example using an Arduino Uno:

Step 1: Gather Components

SG90 servo Arduino Uno Breadboard Jumper wires

Step 2: Wire the Circuit

Orange Wire: Connect to Arduino PWM pin (e.g., pin 9). Red Wire: Link to the 5V pin (for single servo) or an external 5V supply. Brown Wire: Attach to the Arduino’s GND pin.

Step 3: Upload Code Use the Arduino Servo library to control the motor: ```cpp

include

Servo myservo;

void setup() { myservo.attach(9); // Connect to pin 9 }

void loop() { myservo.write(0); // Rotate to 0 degrees delay(1000); myservo.write(90); // Rotate to 90 degrees delay(1000); myservo.write(180); // Rotate to 180 degrees delay(1000); }

python from gpiozero import Servo from time import sleep

servo = Servo(18) # GPIO18

while True: servo.min() # 0 degrees sleep(1) servo.mid() # 90 degrees sleep(1) servo.max() # 180 degrees sleep(1)

Power Considerations for Raspberry Pi - Avoid powering multiple servos directly from the Pi’s 5V pin. Use an external 5V supply (e.g., UBEC) to prevent voltage drops. - Share a common ground between the Pi and the external power source. --- Mastering PWM: How Pulse Width Controls Servo Angle The SG90’s position is determined by Pulse Width Modulation (PWM): - Pulse Width Range: 1 ms (0°) to 2 ms (180°), sent every 20 ms (50 Hz). - Duty Cycle: 5% (1 ms) to 10% (2 ms). Arduino Code for Custom PWM For fine-grained control, use `analogWrite()` or direct timer registers:

cpp

include

Servo myservo;

void setup() { myservo.attach(9); myservo.writeMicroseconds(1500); // Neutral position (90°) }

void loop() {}

--- Building a Pan-Tilt Mechanism: A DIY Project Combine two SG90 servos to create a camera or sensor mount. Components Needed: - 2x SG90 servos - Raspberry Pi/Arduino - Pan-tilt bracket kit - Jumper wires - External 5V power supply Assembly Steps: 1. Mount the servos on the pan-tilt bracket. 2. Connect one servo for horizontal (pan) movement and another for vertical (tilt). 3. Wire both servos to the microcontroller, sharing a common ground and external power. Arduino Code for Dual Servo Control:

cpp

include

Servo panServo; Servo tiltServo;

void setup() { panServo.attach(9); tiltServo.attach(10); }

void loop() { panServo.write(0); tiltServo.write(45); delay(1000); panServo.write(180); tiltServo.write(135); delay(1000); }

--- Real-World Applications of the SG90 Servo 1. Robotic Arms: Control grippers or joints in DIY robotic kits. 2. Solar Trackers: Adjust solar panel angles to follow the sun. 3. Smart Home Devices: Automate blinds, locks, or pet feeders. 4. RC Vehicles: Steer cars or planes in hobbyist models. 5. Camera Gimbals: Stabilize cameras for photography drones. --- Pro Tips for Reliable SG90 Performance 1. Avoid Overloading: The SG90 has a stall torque of ~1.8 kg/cm. Exceeding this can burn out the motor. 2. Use Decoupling Capacitors: Add a 100µF capacitor between VCC and GND to reduce power supply noise. 3. Mechanical Safety: Never force the servo horn manually—this can strip gears. 4. Calibration: If the servo doesn’t reach 180°, adjust PWM limits in code:

cpp myservo.attach(9, 500, 2500); // Custom min/max pulse widths ```

Troubleshooting Common Issues

Jittery Movement: Check for power supply instability. Ensure the control signal isn’t near interference sources (e.g., motors). Servo Doesn’t Move: Verify wiring (signal, power, ground). Test with a known-working servo or microcontroller. Overheating: Disconnect and check for mechanical obstructions.

Conclusion: Unleash Your Creativity The SG90 servo is a gateway to countless projects, from simple gadgets to complex robotics. By mastering its pinout, PWM control, and integration techniques, you’re equipped to tackle challenges in automation and beyond. Start small—wire a single servo, tweak the code, and scale up to multi-servo systems. The only limit is your imagination!

Next Steps:

Experiment with feedback mechanisms (e.g., potentiometers for closed-loop control). Explore 3D printing custom mounts for unique applications. Join maker communities to share ideas and troubleshoot with peers.

With the SG90, every project is an opportunity to learn and innovate. Happy building! 🛠️

Update:2025-09-16

Contact a motor expert for product recommendation.
Contact a motor expert for product recommendation.

Powering The Future

Contact Kpower's product specialist to recommend suitable motor or gearbox for your product.