Uploaded February 2025 | Updated September 2026, 3 weeks ago
Mastering Servo Control with ESP32: 180° vs. 360° Servos
Library ESP32Servo.h
Base TowerPro MG995 and TowerPro MG995R
00:00 How to Control Servo Motors
00:06 TowerPro MG995, TowerPro MG995R
00:17 To control a continuous rotation servo
02:25 Now, let's program a 180-degree servo
03:18 A 180-degree servo's rotation is controlled by angle
05:43 A 180-degree servo application, using a BH1750 sensor
06:50 Dual-core ESP32s allow servo motors to be programmed for multitasking
Servo motors are essential components in robotics, automation, and hobbyist projects, offering precise angular control. The ESP32, with its powerful processing capabilities and the convenient ESP32Servo.h library, makes controlling these motors a breeze. However, understanding the difference between 180° and 360° servos is crucial for successful implementation.
Understanding the Servo Landscape: 180° vs. 360°
180° Servos:
These are the most common type of servo.
They offer precise angular positioning within a limited range, typically 0° to 180°.
You control their position by sending a pulse-width modulated (PWM) signal, with the pulse width determining the angle.
Ideal for applications requiring accurate positioning, such as robotic arms, camera gimbals, and steering mechanisms.
360° (Continuous Rotation) Servos:
Unlike 180° servos, these don't have a fixed angular range.
They rotate continuously, like a standard DC motor.
The PWM signal controls their speed and direction.
The "neutral" pulse width typically stops the motor.
Used in applications requiring continuous motion, such as robotic wheels, rotating platforms, and conveyor belts.
Leveraging ESP32Servo.h for Control
The ESP32Servo.h library simplifies servo motor control with the ESP32. Here's a breakdown of key aspects:
Initialization:
Include the library: ESP32Servo.h
Create a Servo object: Servo myservo;
Attach the servo to a specific GPIO pin: myservo.attach(servoPin); (e.g., myservo.attach(2);)
Controlling 180° Servos:
Use the write() function to set the desired angle: myservo.write(angle); (where angle is between 0 and 180).
Example: myservo.write(90); would move the servo to the 90-degree position.
Controlling 360° Servos:
The write() function is still used, but the values now represent speed and direction.
A value around 90 (or 1500 micro seconds) typically stops the motor.
Values below 90 rotate the motor in one direction, and values above 90 rotate it in the opposite direction.
Example: myservo.write(80); for clockwise rotation, myservo.write(100); for counter-clockwise rotation.
The further away from the neutral point, the faster the motor rotates.
Detaching the Servo:
Use the detach function when you are finished using the servo. myservo.detach();
Calibration: 360° servos may require calibration to find the exact neutral point. This can vary between manufacturers.
Pulse Width: While ESP32Servo.h simplifies control, understanding the underlying PWM signals is beneficial. The library typically maps angle or speed values to corresponding pulse widths.
Pin Selection: Choose GPIO pins that support PWM output for optimal servo control.
ESP32 multi-tasking enables servo programs to operate simultaneously and independently. The ESP32's dual-core architecture allows for separate control of two servos, or the implementation of priority-based commands for sensors, web servers, and other functions
Mastering Servo Control with ESP32: 180° vs. 360° Servos
Library ESP32Servo.h
Base TowerPro MG995 and TowerPro MG995R
00:00 How to Control Servo Motors
00:06 TowerPro MG995, TowerPro MG995R
00:17 To control a continuous rotation servo
02:25 Now, let's program a 180-degree servo
03:18 A 180-degree servo's rotation is controlled by angle
05:43 A 180-degree servo application, using a BH1750 sensor
06:50 Dual-core ESP32s allow servo motors to be programmed for multitasking
Servo motors are essential components in robotics, automation, and hobbyist projects, offering precise angular control. The ESP32, with its powerful processing capabilities and the convenient ESP32Servo.h library, makes controlling these motors a breeze. However, understanding the difference between 180° and 360° servos is crucial for successful implementation.
Understanding the Servo Landscape: 180° vs. 360°
180° Servos:
These are the most common type of servo.
They offer precise angular positioning within a limited range, typically 0° to 180°.
You control their position by sending a pulse-width modulated (PWM) signal, with the pulse width determining the angle.
Ideal for applications requiring accurate positioning, such as robotic arms, camera gimbals, and steering mechanisms.
360° (Continuous Rotation) Servos:
Unlike 180° servos, these don't have a fixed angular range.
They rotate continuously, like a standard DC motor.
The PWM signal controls their speed and direction.
The "neutral" pulse width typically stops the motor.
Used in applications requiring continuous motion, such as robotic wheels, rotating platforms, and conveyor belts.
Leveraging ESP32Servo.h for Control
The ESP32Servo.h library simplifies servo motor control with the ESP32. Here's a breakdown of key aspects:
Initialization:
Include the library: ESP32Servo.h
Create a Servo object: Servo myservo;
Attach the servo to a specific GPIO pin: myservo.attach(servoPin); (e.g., myservo.attach(2);)
Controlling 180° Servos:
Use the write() function to set the desired angle: myservo.write(angle); (where angle is between 0 and 180).
Example: myservo.write(90); would move the servo to the 90-degree position.
Controlling 360° Servos:
The write() function is still used, but the values now represent speed and direction.
A value around 90 (or 1500 micro seconds) typically stops the motor.
Values below 90 rotate the motor in one direction, and values above 90 rotate it in the opposite direction.
Example: myservo.write(80); for clockwise rotation, myservo.write(100); for counter-clockwise rotation.
The further away from the neutral point, the faster the motor rotates.
Detaching the Servo:
Use the detach function when you are finished using the servo. myservo.detach();
Calibration: 360° servos may require calibration to find the exact neutral point. This can vary between manufacturers.
Pulse Width: While ESP32Servo.h simplifies control, understanding the underlying PWM signals is beneficial. The library typically maps angle or speed values to corresponding pulse widths.
Pin Selection: Choose GPIO pins that support PWM output for optimal servo control.
ESP32 multi-tasking enables servo programs to operate simultaneously and independently. The ESP32's dual-core architecture allows for separate control of two servos, or the implementation of priority-based commands for sensors, web servers, and other functions










