PWM Duty Cycle Calculator: Period, On-Time, and Average Voltage
Turn frequency and PWM duty cycle into period, on-time, off-time, and average voltage. A practical guide for Arduino LED dimming and motor speed control.
PWM Duty Cycle Calculator: Period, On-Time, and Average Voltage
Pulse-width modulation looks like one of those topics that should be simple, and the core of it is. A digital pin flips between high and low, and the only thing you control is what fraction of each cycle it stays high. That fraction is the duty cycle, and almost every LED brightness trick, motor speed setting, and heater control on a microcontroller comes back to it. The trouble starts when you need to translate a duty cycle into something physical: how many microseconds the pin is actually high, what average voltage the load feels, and whether the frequency you picked is fast enough for the job.
This guide walks through the math, runs one example end to end, and points out the two or three places people trip. If you just want the numbers, the PWM Duty Cycle Calculator does all of it in your browser.
What duty cycle actually means
Duty cycle is the percentage of one full PWM period that the signal stays high. Write it as a fraction and the whole rest of the math falls out. A 50 percent duty cycle is a symmetric square wave: high for half the cycle, low for the other half. A 25 percent duty cycle is high for a quarter of the cycle and low for the remaining three quarters.
The one definition worth memorizing is this:
duty cycle = on time / period
Everything else is rearranging that sentence. If you know the period and the duty, you know the on-time. If you measured the on-time on a scope and you know the period, you can back-solve the duty. That reversibility is exactly why a calculator with a reverse mode is handy — more on that below.
Higher duty means more energy reaches the load per cycle, which is why duty cycle is the knob you turn to brighten an LED or speed up a motor. Push it to 100 percent and the pin stays high the whole time; drop it to 0 percent and it stays low. Neither of those endpoints is really switching anymore — they are steady DC.
Frequency and period are reciprocals
Before you can find an on-time, you need the period, and the period comes from the frequency:
T = 1 / f
Frequency is how many complete cycles happen each second, measured in hertz. A 1 kHz signal repeats a thousand times a second, so each cycle lasts 1 / 1000 = 0.001 seconds, or 1 millisecond. A 20 kHz motor-drive carrier has a period of 1 / 20000 = 50 microseconds.
This is where the first mistake creeps in. Frequency and period are inverses of each other, and it is easy to type a frequency value into a field that expects seconds, or vice versa. Get them swapped and your answer is off by a factor of a million. The period is the total time budget; the on-time and off-time split that budget between them.
A worked example, start to finish
Let's take the canonical case: a 1 kHz signal at 50 percent duty cycle, running off a 5 V rail.
- Period: T = 1 / 1000 = 1 ms.
- On-time: t_on = T × duty = 1 ms × 0.5 = 500 microseconds.
- Off-time: t_off = T − t_on = 1 ms − 500 µs = 500 microseconds.
- Average voltage: Vavg = Vcc × duty = 5 V × 0.5 = 2.5 V.
So a 50 percent duty cycle gives you exactly half the average voltage — 2.5 V from a 5 V supply. That clean halving is the intuition to hold onto: duty cycle scales the average voltage linearly. Bump the duty to 40 percent and the average drops to 2 V; raise it to 75 percent and you get 3.75 V, with the pin high for 750 microseconds and low for 250.
The average-voltage relationship only holds for a load that responds slowly compared to the switching frequency, or one with a filter in front of it. A motor winding or a capacitor smooths the pulses into something that behaves like a steady 2.5 V. An LED stared at directly does not — it sees the full 5 V pulses snapping on and off, and only your eye's persistence averages them.
Picking a frequency for LEDs and motors
The duty cycle sets the brightness or speed; the frequency decides whether the result is usable.
For LED dimming, stay above roughly 200 Hz so the human eye stops seeing flicker. A 1 kHz default is a safe choice that also dodges the banding you get when a phone camera's rolling shutter beats against a slow PWM. If you have ever filmed a dimmed LED strip and seen dark stripes scroll across the frame, that is the PWM frequency being too low for the camera.
For brushed DC motors, a few hundred hertz to a few kilohertz moves the motor fine, but the switching often sits right in the audible range and the motor whines. The common fix is to push the carrier up to 20 kHz, above human hearing, so the motor runs quietly. The duty cycle still sets the speed; only the carrier moves.
Hobby servos are the exception that catches everyone. A servo expects a roughly 50 Hz frame — a 20 ms period — with a pulse between 1 and 2 ms wide. That works out to a duty cycle of only 5 to 10 percent, which is why servo libraries think in microseconds of pulse width rather than a percentage. Set a servo to "50 percent duty" and you send a 10 ms pulse that slams it against an end stop.
Reverse-solving from a scope reading
The first time this calculator earned its keep for me, my firmware insisted it was generating 40 percent duty, but the scope showed a 360 microsecond high pulse at 1 kHz. I switched to reverse mode, entered the 360 µs on-time and the 1 kHz frequency, and it back-solved 36 percent. That four-point gap told me the timer prescaler or compare value was off by a notch — a register problem, not the phantom load issue I had been about to chase for an hour. The reverse mode turns "duty = on time / period" inside out: feed it the measured on-time and the frequency, and it hands you the duty the hardware is actually producing.
That sanity check is worth doing any time the firmware's claimed duty and the physical behavior disagree. A timer that is configured slightly wrong will happily report the value you wrote to it while emitting something else entirely.
Putting it together
PWM is three relationships stacked on top of each other: period from frequency, on-time from period and duty, and average voltage from duty and supply. Once those click, you can read a datasheet's PWM section, set an analogWrite value, or debug a misbehaving motor driver without second-guessing the arithmetic. If your project also needs a current-limiting resistor for that LED, the Ohm's Law calculator handles the V = IR side of the same circuit.
Plug your own frequency, duty, and supply voltage into the PWM Duty Cycle Calculator, and the period, on-time, off-time, and average voltage all update together — with a reverse mode for when the scope and the firmware tell different stories.
Made by Toolora · Updated 2026-06-13