ESP32 Servo Motor Not Moving with PWM
DodaTech
Updated 2026-06-26
1 min read
In this tutorial, you'll learn about ESP32 Servo Motor Not Moving with PWM. We cover key concepts, practical examples, and best practices.
The Problem
ESP32 PWM control of a servo motor results in no movement, jittering, or incorrect positioning.
Quick Fix
Wrong
ledcSetup(0, 50, 10);
ledcAttachPin(13, 0);
ledcWrite(0, 128); // Servo does not move
Servo stays at one position or buzzes without moving.
Right
const int servoPin = 13;
const int freq = 50;
const int res = 16;
ledcSetup(0, freq, res);
ledcAttachPin(servoPin, 0);
int angle = 90;
int pulseWidth = map(angle, 0, 180, 500, 2500);
ledcWrite(0, pulseWidth * 65536 / 20000);
Servo moves to 90 degrees position smoothly.
Prevention
Use 50 Hz frequency for standard servos. Pulse width range: 500-2500 microseconds (0-180 degrees). Use 16-bit resolution for precise pulse widths. Provide enough power (5V, 2A+) for servo. Do not use USB power for multiple servos.
DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro