Sub topic 3
From Duty Cycle to Average Voltage and Brightness
This chapter assumes that you know the Arduino setup() and loop() structure, can configure a pin with pinMode(), and understand basic breadboard wiring and Ohm’s law. The focus here is how a rapidly switching digital signal can produce a controllable average effect.
A digital pin switches, rather than producing every voltage
A typical Arduino Uno digital output has two useful states:
LOW, close to 0 VHIGH, close to 5 V
It does not normally produce a steady 2.5 V or 3.7 V on demand. Pulse-width modulation, or PWM, works around this limitation. The pin switches between HIGH and LOW many times each second.
A PWM signal has a repeating period. The period is the time from the beginning of one pulse to the beginning of the next. During each period, the signal stays HIGH for part of the time and LOW for the rest.
The duty cycle is the fraction of one period spent HIGH:
\[ \text{duty cycle} = \frac{\text{high time}}{\text{period}} \]
It is usually written as a percentage.
| Duty cycle | Signal high during each period | Ideal average voltage from a 5 V pin |
|---|---|---|
| 0% | 0% of the period | 0 V |
| 25% | One quarter of the period | 1.25 V |
| 50% | Half of the period | 2.5 V |
| 75% | Three quarters of the period | 3.75 V |
| 100% | The entire period | 5 V |
The average voltage is approximately:
\[ V\text{average} = V\text{high} \times \text{duty cycle} \]
Use the duty cycle as a decimal in this equation. For example, a 60% duty cycle from a 5 V output has an ideal average voltage of:
\[ 5 \times 0.60 = 3.0\text{ V} \]
The pin is still switching between 0 V and 5 V. A multimeter may display a value near 3 V because it averages the rapidly changing signal. The pin has not become a true adjustable voltage source.
Why an LED appears dimmer
An LED responds to the pulses of current. When the PWM signal is HIGH, current flows through the LED and its resistor. When the signal is LOW, current stops.
At a high enough PWM frequency, the switching is too fast for your eyes to distinguish each pulse. Your visual system combines the light over time. A 25% duty cycle therefore appears dimmer than a 75% duty cycle because the LED emits light for less time in each period.
This explanation assumes that the LED current during its HIGH time is safe and approximately constant. The current-limiting resistor remains necessary. PWM does not protect an LED from excessive current during the HIGH portion of the cycle.
Average power and brightness are different measurements
For many simple loads, increasing duty cycle increases average power. However, average voltage is only a convenient model. The actual current depends on the load.
An LED is nonlinear: its current does not increase in a simple straight line with voltage. Its perceived brightness is also nonlinear. A change from 10% to 20% duty cycle does not usually look as large as a change from 50% to 60%, even though both changes are 10 percentage points.
This happens for two reasons:
- The LED’s electrical behavior is nonlinear.
- Human vision responds approximately logarithmically to light intensity.
Consequently, equal numerical PWM steps do not appear as equal brightness steps. A later chapter will use gamma correction to transform the control values so a fade looks more even.
For an LED circuit, duty cycle is best understood as a control of the LED’s average light output, not as a direct command for a measured voltage. The resistor sets the peak current, while PWM sets how long that current flows during each period.
Exercise
A 5 V PWM signal has a 30% duty cycle. What is its ideal average voltage, and what happens to the LED during the remaining 70% of each period?
Show answer
The ideal average voltage is 5 × 0.30 = 1.5 V. During the remaining 70%, the pin is LOW, so the LED receives no current in that part of the period.