Pulse Width Modulation (PWM) is the standard for controlling LED brightness, in professional lighting as well as PCB art.

This article explores what PWM is, why it’s widely preferred over alternative methods, and how to implement it effectively.

What is Pulse Width Modulation?

PWM is a technique that controls the average power delivered to an electronic device by rapidly switching the power on and off. For LEDs, this means turning the LED completely on and completely off at a frequency typically higher than the human eye can detect (usually >100 Hz).

The key parameter in PWM is the duty cycle - the percentage of time the signal is in the “on” state compared to the total period:

  • A 0% duty cycle means the LED is completely off
  • A 100% duty cycle means the LED is fully on
  • A 50% duty cycle means the LED is on half the time, resulting in what appears to be half brightness

The human eye integrates this rapid switching, perceiving it as a continuous light at a reduced brightness level proportional to the duty cycle.

Live demonstration

This demonstration shows how PWM works. The frequency is much lower than would be used in reality to show what is going on; in practice the frequency would much higher than the eye can see.

Why PWM is Used for LED Brightness Control

Consistent Color Reproduction

One of the most significant advantages of PWM is its ability to maintain consistent color characteristics across brightness levels. With analog dimming methods (like reducing current), the color temperature and spectrum of an LED can shift as power changes. PWM ensures the LED operates at either full rated current or zero current, preserving its designed spectral properties.

For RGB LEDs and complex lighting systems, this color consistency is crucial. PWM allows precise color mixing without unwanted hue shifts when dimming.

Linear Brightness Control

PWM offers nearly linear brightness control relative to the duty cycle. This means that a 50% duty cycle produces perceived brightness that’s approximately 50% of maximum, making calibration and control much more intuitive.

In contrast, analog methods suffer from a non-linear relationship between current and perceived brightness due to the human eye’s logarithmic sensitivity to light and the LED’s own non-linear current-to-light output relationship.

Energy Efficiency

When an LED is on, PWM drives it at its rated current where it operates most efficiently. Traditional current-limiting methods like resistive dimming waste energy as heat. In battery-powered applications, this efficiency advantage becomes particularly important.

Extended LED Lifespan

LEDs have rated current specifications for optimal operation. Analog dimming can potentially drive LEDs outside their optimal parameters, while PWM ensures the LED always operates at its designed current when on, potentially extending its operational lifespan.

Simple Implementation

Modern microcontrollers and dedicated LED driver ICs typically include built-in PWM capabilities, making implementation straightforward. Many systems require only a few lines of code to set up PWM control.

Alternatives to PWM

Current Control

This method involves actively limiting the current through the LED to reduce brightness. In constrast, PWM fully flips the LED completely on and off. There are several drawbacks vs. PWM dimming:

  • Color shifting: LEDs change their spectral output at different current levels; this is a particular problem for white LEDs
  • Non-linear response: The relationship between current and perceived brightness is not linear
  • Efficiency loss: Linear current-limiting components dissipate power as heat; however, switch-mode regulators can be more efficient
  • Complexity for multiple channels: Requires separate control circuitry for each LED
  • External drivers: typically external driver ICs must be used

It also has several advantages:

  • Temperature control: It controls for the fact that the power consumption of LEDs changes with temperature
  • Potentially greater efficiency: Depending on the method used, it can be more power efficient than PWM
  • No current-limiting resistors needed: It can obviate the need for and be more efficient than current-limiting resistors, which burn off current as heat

Voltage Control

Voltage control attempts to dim LEDs by reducing the voltage applied to the LED circuit. This approach is fundamentally flawed for LEDs for several reasons:

  • Non-linear voltage-current relationship: LEDs have an exponential relationship between voltage and current. A small change in voltage can cause a large change in current, making precise brightness control extremely difficult.
  • Threshold behavior: LEDs have a forward voltage threshold (typically 1.8V-3.3V depending on color) below which they conduct almost no current, and above which current increases rapidly. This creates a narrow usable voltage range.
  • Temperature sensitivity: The voltage-current relationship of LEDs changes with temperature, making voltage control unreliable in varying environmental conditions.
  • Manufacturing variations: Even LEDs from the same batch can have different voltage-current characteristics, causing inconsistent brightness across multiple LEDs when using voltage control.
  • Risk of thermal runaway: As LEDs warm up, their forward voltage typically decreases. With voltage control, this can lead to increasing current as the LED operates, potentially causing damage.

Due to these limitations, voltage control is generally considered unsuitable for LED brightness control.

PWM Implementation Considerations

Frequency Selection

The PWM frequency must be high enough to prevent visible flickering. While the human eye typically cannot detect flicker above 60-90 Hz, higher frequencies (1 kHz or more) are often used to ensure:

  • No visual flicker, even in peripheral vision
  • No camera interference (important for environments where video recording occurs)
  • No audible noise (LEDs and their driving circuits can sometimes produce high-pitched whines at certain frequencies)

However, very high frequencies can reduce efficiency due to switching losses and may introduce EMI/RFI concerns.

Resolution Requirements

The bit depth of PWM control determines how many distinct brightness levels are available:

  • 8-bit PWM: 256 brightness levels (common in hobby projects)
  • 10-bit PWM: 1,024 brightness levels (typical for consumer products)
  • 12-bit or higher: 4,096+ brightness levels (used in professional lighting)

Higher resolution allows for smoother dimming, especially at low brightness levels where the human eye is most sensitive to changes.

Hardware vs. Software PWM

PWM can be implemented in hardware (using dedicated timer peripherals) or software (using programmed delays).

In software PWM, we write firmware to drive the PWM phasing. In hardware PWM, we configure a hardware timer in the microcontroller to drive the PWM signal directly, requiring virtually no CPU clock cycles.

  • Hardware PWM: More precise timing, lower CPU overhead, but limited to specific pins
  • Software PWM: More flexible pin selection, but higher CPU usage and potentially less precise

Hardware PWM is generally preferred when available.

Advanced PWM Techniques

Bit-Angle Modulation (BAM)

For very high-resolution control with limited hardware capabilities, BAM techniques can be used to achieve more perceived brightness levels than the PWM hardware supports natively.

Phase-Shifted PWM

Phase-shifted PWM is a technique used in multi-channel LED systems where the PWM signals for different channels are deliberately offset in time while maintaining the same frequency and duty cycle.

Instead of having all LED channels turn on and off simultaneously, phase-shifting staggers their timing. For example, in a 4-channel system, each channel might be shifted by 25% of the period (90 degrees in phase terms) from the previous one.

This approach offers several benefits:

  • Reduced peak current draw: By preventing all LEDs from turning on simultaneously, the maximum instantaneous current is reduced, placing less stress on power supplies
  • Minimized power supply ripple: The more even distribution of power demands results in less voltage fluctuation
  • Reduced electromagnetic interference (EMI): Smoother power consumption creates fewer electromagnetic disturbances
  • Thermal management: More evenly distributed power consumption can lead to better thermal performance

Phase-shifted PWM is particularly valuable in applications with many LEDs or those requiring stable power delivery, such as automotive lighting systems, large LED displays, and professional lighting installations.

For low-power PCB art, having a lot of LEDs on at once can cause voltage drop in the entire circuit, which can cause the microcontroller to brown out and behave unpredictably, which must be prevented if at all possible. Phase-shifted PWM can help against this.

Combining PWM with Current Control

Some systems combine PWM with limited analog control to achieve the benefits of both methods, especially in high-end lighting applications.

Conclusion

Pulse Width Modulation has become the industry standard for LED control because it delivers superior color consistency, linear control, energy efficiency, and simplicity.

PWM is a foundation of modern lighting control systems from everything from tiny indicator lights to massive architectural lighting installations.

Understanding PWM principles allows engineers and designers to create more efficient, effective, and visually pleasing LED-based systems.