ATmega168A pulse width modulation (PWM)

ProtoStack shows how to dim a LED using pulse width modulation and an ATmega168A:

Dimming an incandescent bulb is easy. Simply adjust the current down using a potentiometer and you are done. Dimming an LED is another story entirely. When you reduce current through an LED there are unintended consequences like color shifts and dropouts. A better way is to use Pulse Width Modulation (PWM).

With PWM the LED is turned on and off many times per second. By adjusting the percentage of on time vs off time, the brightness of the LED can be controlled. The diagram below shows 4 PWM wave forms with varying duty cycles. The 90% duty cycle example would produce the greatest brightness whilst the 10% duty cycle will produce the least. The selected period should be sufficiently short so that a flicker isn’t noticeable.

Thanks Daniel! Via the contact form.

Leave a comment

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.