To achieve a completely flicker-free LED setup on an ESP32, use the built-in
LEDC (LED Control) peripheral configured to
25,000 Hz (25 kHz) with an
11-bit resolution. [
1,
2,
3]
The ESP32 features dedicated hardware timers specifically designed to maintain exact PWM frequencies without lagging or consuming CPU power. [
1,
2]
Optimal ESP32 LEDC Settings
The ESP32 imposes a strict hardware math limit: as your PWM frequency goes
up, your maximum available bit resolution goes
down. The following configurations balance this tradeoff: [
1,
2]
- Ultimate Choice (Camera-Safe & Silent): Set to 25,000 Hz at 11-bit resolution (0 to 2047 steps). This completely avoids camera banding, eliminates audible capacitor whine, and provides smooth dimming steps.
- Maximum Smoothness (Slight Videography Risk): Set to 5,000 Hz at 13-bit resolution (0 to 8191 steps). This provides incredibly precise, cinematic dimming fades, but may cause light banding on ultra-high-speed camera shutters.
- The Hardware Limit: The absolute highest frequency you can reach on the ESP32 while maintaining a usable 8-bit dimming resolution (0 to 255 steps) is 312.5 kHz