Skip to content

ESP32 PWM Frequency Too Low Causes Flicker

DodaTech Updated 2026-06-26 1 min read

In this tutorial, you'll learn about ESP32 PWM Frequency Too Low Causes Flicker. We cover key concepts, practical examples, and best practices.

The Problem

ESP32 PWM output at low frequency causes visible flicker in LEDs or audible noise from motors.

Quick Fix

Wrong

ledcSetup(0, 50, 10);  // 50 Hz for LEDs - visible flicker
LED visibly flickers. Camera recordings show rolling bands.
ledcSetup(0, 5000, 10);  // 5 kHz - no visible flicker
// Or use 20000 (20 kHz) to avoid audible coil whine
ledcAttachPin(2, 0);
ledcWrite(0, 200);
LED appears steady. No flicker visible. No audible noise.

Prevention

Use 1-5 kHz for LEDs. Use 20 kHz+ for motor drivers (above human hearing). Check camera shutter speed compatibility (use 10 kHz+ for video). Higher frequency reduces efficiency but eliminates flicker.

DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.

FAQ

### What is the maximum PWM frequency on ESP32?

Maximum PWM frequency depends on resolution: 40 MHz / 2^resolution. At 8-bit (256 steps), max is 312.5 kHz. At 16-bit, max is ~610 Hz.

Does higher frequency affect brightness?

Higher frequency at the same duty cycle reduces LED efficiency slightly. The difference is minimal for frequencies under 20 kHz.

Can I change frequency at runtime?

Yes. Call ledcSetup() again with the new frequency. This resets the channel, so you must reattach pins and set duty cycle.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro