Arduino UNO Servo Motor Connection

A servo motor is a small device used for precise control of position, angle, and rotation. It is widely used in robotics, automation, and embedded systems.

With Arduino UNO, controlling a servo motor is simple using PWM (Pulse Width Modulation) signals.

In this tutorial, you will learn how to connect a servo motor to Arduino UNO and control its movement using simple code.

1. Required Components

Arduino UNO board

Servo Motor (SG90 or similar)

Jumper wires

USB cable for power

2. Servo Motor Wiring

A servo motor typically has three wires:

Red → VCC (5V power supply)

Brown/Black → Ground (GND)

Yellow/Orange → Signal (PWM pin)

Connect the signal wire to Arduino digital pin 9, which supports PWM output.

3. Connection Summary

Servo VCC → Arduino 5V

Servo GND → Arduino GND

Servo Signal → Digital Pin 9

4. Arduino Code

Program: Servo motor control example
#include <Servo.h>

Servo myServo;

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

void loop() {
    myServo.write(0);   // move to 0 degree
    delay(1000);

    myServo.write(90);  // move to 90 degree
    delay(1000);

    myServo.write(180); // move to 180 degree
    delay(1000);
}

This program rotates the servo motor between 0°, 90°, and 180° positions with a delay between each movement.

5. Working Principle

Servo motors operate based on PWM (Pulse Width Modulation) signals sent by the Arduino.

The width of each pulse determines the angle of rotation of the servo motor shaft.

The Servo library simplifies this process by internally generating the required PWM signals.

6. Common Mistakes

Incorrect connection of VCC and GND can damage the servo motor.

Using a non-PWM pin for signal connection.

Insufficient power supply leading to unstable movement.

Loose wiring connections causing erratic behavior.

7. Best Practices

Use an external power supply when working with multiple servos.

Always connect the ground properly between Arduino and servo.

Avoid forcing the servo beyond its 0° to 180° range.

Ensure secure wiring to avoid noise and signal interruptions.

Conclusion

Connecting a servo motor with Arduino UNO is simple and forms the foundation for many robotics and automation projects.

Using the Servo library makes it easy to control angles precisely with minimal code.

Practice this setup and extend it to build more advanced projects like robotic arms and smart systems.