Shop by category
Shop all componentsSensors & MCUs
ESP32 core 3.x uses ledcAttach(pin, freq, bits); core 2.x uses ledcSetup and ledcAttachPin.
Max bits = floor(log2(80,000,000 ÷ f))Duty value = duty % × (2^bits − 1) ÷ 100At 5 kHz: log2(80,000,000 ÷ 5,000) = 13.97, so up to 13 bits. A 10-bit setting is allowed, and 50% duty is a value of 512 out of 1023. At 20 kHz you get at most 11 bits.
The ESP32 LEDC peripheral divides an 80 MHz clock to make PWM, so higher frequencies leave fewer counter steps per period and therefore less resolution. Pick the frequency to suit the load, then the largest resolution that fits.
Use 20 kHz or more for motors and LED dimming to avoid audible noise, and 1–5 kHz for most LEDs. For servo signals, use 50 Hz with 14–16 bits.
floor(log2(80 MHz ÷ 5 kHz)) = 13 bits.
Resolution × frequency is limited by the 80 MHz clock. Higher frequency leaves fewer bits.
1 to 5 kHz for LEDs; 20 kHz or more for silent DC motor control.
Max bits = floor(log2(80,000,000 ÷ f)); Duty value = duty % × (2^bits − 1) ÷ 100.
At 5 kHz: log2(80,000,000 ÷ 5,000) = 13.97, so up to 13 bits. A 10-bit setting is allowed, and 50% duty is a value of 512 out of 1023. At 20 kHz you get at most 11 bits.
Geekobot builds that use it include Wi-Fi room occupancy sensor, Wi-Fi UV index monitor, Wi-Fi noise monitor and Wi-Fi nursery climate monitor. Each has the full parts list, wiring and code.
Results are estimates for design and learning. Check critical designs against the component datasheet. Made by the Geekobot Learning Team. How we write our calculators