6.4 Servo Motors
6.4.1 Introduction
A servo motor is an actuator used to control angular position.
Unlike a simple DC motor, a servo motor can be commanded to move to a particular position.
Typical hobby servos can rotate through approximately 180°, although the actual range depends on the servo model.
6.4.2 Types of Servo Motors
Common types include:
- Positional servo
- Continuous rotation servo
- Linear servo
Examples of hobby servos include:
- SG90
- MG90S
- MG996R
6.4.3 Components
A typical servo has:
- Power wire
- Ground wire
- Signal wire
Typical colors vary by manufacturer, so the labels or datasheet should be checked.
6.4.4 Working Principle
The Arduino sends a control signal to the servo.
The servo’s internal electronics and motor mechanism move the shaft toward the commanded position.
For a standard positional servo:
Arduino → Control Signal → Servo → Shaft Movement
6.4.5 Connection to Arduino
Example:
|
Servo |
Arduino |
|
Signal |
D9 |
|
VCC |
5V/external suitable supply |
|
GND |
GND |
For larger servos, an external power supply may be required. The Arduino and external supply should share a common ground when appropriate.
6.4.6 Servo Library
Arduino provides the Servo library.
#include <Servo.h>
Important functions include:
- attach()
- write()
- detach()
6.4.7 Arduino Programming and 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);
}
6.4.8 Code Description
- Servo.h provides servo control functions.
- Servo myServo creates a servo object.
- attach(9) connects the servo signal to pin 9.
- write(0) moves the servo toward 0°.
- write(90) moves it toward 90°.
- write(180) moves it toward 180°.
- delay() provides time between movements.
6.4.9 Applications
Servo motors are used in:
- Robotic arms
- Automatic doors
- Camera positioning
- Robot steering
- Model systems
- Lock mechanisms
- Solar tracking systems


