Skip to content
Home > Components > Actuators > Servo Motor

Servo Motor

An actuator that uses a feedback loop for precise angular position control, typically across a 180° range.

Component Preview

Servo MotorStandard Servo

A hobby servo motor provides precise angular position control. The position is controlled by sending a specific PWM signal to the control wire. Using the Arduino Servo library simplifies this process down to passing an angle (0 to 180).

ActuatorsMotorPWM

Overview

The servo motor uses an internal potentiometer and control circuit to form a feedback loop. When you tell it to go to an angle, it turns the motor until the potentiometer reads the correct voltage for that angle.

PWM Timing

The servo expects a pulse every 20ms (50Hz). The length of the pulse determines the position:

  • 1.0 ms: 0° (Minimum angle)
  • 1.5 ms: 90° (Center position)
  • 2.0 ms: 180° (Maximum angle)

Pin Reference

PinTypeDescription
GNDpowerGround (Usually Brown or Black wire).
V+power5V Supply (Usually Red wire).
PWMdigitalPWM Control Signal (Usually Orange, Yellow, or White wire).

Configurable Attributes

AttributeTypeDefaultDescription
anglenumber0Initial angle of the servo motor (0 to 180).
horn-colorstring"white"Color of the servo horn.

Wiring Diagram (Arduino Uno)

Wiring Diagram

(Note: In real hardware, servos can draw significant current, so a dedicated external 5V power supply is often required if you are using multiple servos or a heavy load).

Example Arduino Code

This example uses the built-in Servo library to sweep the motor back and forth.

cpp
#include <Servo.h>

Servo myServo;

void setup() {
  myServo.attach(9); // Attach servo to pin 9
  Serial.begin(9600);
  Serial.println("Servo Motor Ready");
}

void loop() {
  // Sweep from 0 to 180 degrees
  for (int pos = 0; pos <= 180; pos += 1) {
    myServo.write(pos);
    delay(15);
  }
  
  delay(1000);
  
  // Sweep from 180 to 0 degrees
  for (int pos = 180; pos >= 0; pos -= 1) {
    myServo.write(pos);
    delay(15);
  }
  
  delay(1000);
}

Simulation Notes

  • Right-click the servo on the canvas during simulation to manually set the angle via the context menu slider. This allows you to verify behavior without waiting for your code to sweep the full range.

Released under the MIT License.