ESP32 LEDC PWM Calculator

Calculate ESP32 LEDC PWM frequency, duty resolution, divider, and duty values. Use practical settings for ESP-IDF and Arduino firmware projects.

LEDC PWM calculator

Inputs

Outputs

Required divider (exact)-
Divider (1/256 step)-
Divider validity-
Max duty value-
Duty value-
Actual frequency-
Frequency error-
Suggested max resolution-
Enter LEDC settings to calculate PWM values.

Arduino output example


            

ESP-IDF output example


            

What is ESP32 LEDC PWM?

LEDC is the ESP32 PWM peripheral used for LED dimming, motor control, buzzers, and many firmware timing tasks with configurable frequency and duty resolution.

PWM frequency vs duty resolution

Higher PWM frequency usually requires lower duty resolution. Lower frequency gives more room for higher resolution, which is useful for smoother dimming.

How to calculate ESP32 LEDC divider

A practical formula is pwm_freq = clock / (divider * 2^resolution). Rearranging gives divider = clock / (pwm_freq * 2^resolution).

Common ESP32 PWM settings

Use case Frequency Resolution Notes
LED dimming1 kHz10-12 bitSmooth brightness control
Servo control50 Hz12-16 bitPulse width control
Motor PWM20 kHz8-10 bitAbove audible range
Buzzer2 kHz8 bitSimple tone output
High speed PWM40 kHz8 bitLower resolution at higher frequency

Arduino and ESP-IDF output notes

Clock source options, divider range, and APIs can vary by ESP32 family and SDK version. Use these values as practical starting points and verify in your target environment.

FAQ

What is ESP32 LEDC?

ESP32 LEDC is a hardware PWM block that controls output frequency and duty with configurable timer and resolution settings.

How do frequency and duty resolution affect each other?

For a fixed clock, increasing frequency leaves less divider room, so the maximum usable duty resolution decreases.

What PWM frequency should I use for motors or LEDs?

It depends on the load. LEDs often use around 1 kHz, while motor PWM is often set near or above the audible range such as 20 kHz.

Why is my ESP32 PWM frequency not exact?

Divider steps and hardware constraints can force rounding, so actual frequency can differ slightly from the requested target.

Related tools