Robotics 101: Actuators

Servo Motors

What is a Servo Motor?

A servo motor is a small, compact device used to rotate parts of a machine with high precision.

Unlike a standard motor that just spins round and round like a fan, a servo is designed to go to a specific angle and hold that position. If you tell a servo to move to 90 degrees, it moves there and fights to stay there.

Servo Anatomy

The Motor Spectrum

Before we start coding, it's crucial to understand where Servos fit in the world of motors.

Regular DC Motor

  • Role: The Muscle
  • Control: Dumb (On/Off)
  • Wires: 4 (2 Power + 2 H-Bridge)
  • Best For: High speed fans, propellers
Hybrid

Continuous Servo

  • Role: The Hybrid
  • Control: Speed & Direction
  • Wires: 3 (Direct to Pin)
  • Best For: Driving robot wheels

Standard Servo

  • Role: The Artist
  • Control: Exact Angle
  • Wires: 3 (Direct to Pin)
  • Best For: Arms, grippers, steering

Interactive Lab: Types of Servos

Not all servos are the same. Switch tabs below to see the difference between the two main types.

Interactive Servo LabMODE: POSITION (180°)

090180
Signal Analysis
Pulse Width:1.50 msDuty Cycle:7.5 %Command:write(90)
OSCILLOSCOPE
MG90S
standard

Key Characteristics

  • Range:0° to 180° (Limited)
  • Control:Go to specific Angle
  • Behavior:Holds position against force

Best Used For...

  • Robot Arms: Joints need precise angles.
  • Grippers: Open vs. Closed states.
  • Steering: R/C car front wheels.

How It Works Inside

A standard servo uses a potentiometer attached to the output shaft. This acts as a feedback sensor.

  1. You send a PWM signal (e.g., 1.5ms pulse for 90°).
  2. The internal circuit reads the potentiometer to know the current angle.
  3. If there's a difference, the motor spins to correct it.
  4. Once the angles match, the motor stops (but keeps power to hold position).

Code Example

Tell the servo exactly where to go. It handles the rest.

standard_servo.ino
1#include <Servo.h>
2
3Servo myServo;
4
5void setup() {
6  myServo.attach(D2); 
7}
8
9void loop() {
10  myServo.write(0);   // Go to 0 degrees
11  delay(1000);
12  
13  myServo.write(90);  // Go to 90 degrees (Middle)
14  delay(1000);
15  
16  myServo.write(180); // Go to 180 degrees
17  delay(1000);
18}

Quick Wiring Guide

This wiring applies to both types of servos.

wiring_guide.txt
⚠ CRITICAL WARNINGDO NOT CONNECT TO 9V! You will fry the servo's brain. Use 3.3V or 5V only.
BROWN/BLACK→ GND (Ground)RED→ Power (5V)ORANGE/YELLOW→ Signal (Digital Pin)