Getting Started

(lily) #1

Chapter 7: Microcontroller Interrupts and Timers


Pulse Width Modulation – LED Brightness Control

en w n an f at equal intervals, we get a pulse
e frequency is the number of pulses we
referred to as Hz pronounced ‘hurts’ named after
, you can

n is high half the time and low half the time.
,
f, to 1 0%, a

We have set up our LEDs so that the Port D pins source +3v to turn them on.
no current flows so the LEDs are off. The
stors providing 9 mA of current and a power of
for LEDs. In the
me. The
time, so
atts. By cutting the on time in half, we get a
135/2 = 0.00675 watts, less power and less light output.
y, I think I see a way to control the LED brightness. If we keep the frequency
pulses constant, but lower or raise the on time it is on, we can control the
t output from it.


Pu


Wh e continuously turn a port pin o d of
train like the system clock. The puls
generate in one second, usually
the Hertz rental car company. Okay, I lied; it is actually named for... hey
Google this as easily as I can.


For an equal interval pulse train the pi
This is called a 50% duty cycle (Figure 17). We can vary the duty cycle from 0%
always of 0 lways on, or anything in betw
een.


When the pin is set to low, 0 volts,
current flows thru 330-ohm resi
.027 watts. That’s not much power for light bulbs, but enough
precision blinking project we were only giving the LED power half the ti
on/off time doubles for each LED, but they are all on for only half the
they are using only .027/2 = 0.0135w
25% duty cycle and 0.0
He
of
power to the LED and the ligh


50 % Duty Cycle

75 % Duty Cycle

25% Duty Cycle

Figure 17: Pulse Width Modulation Duty Cycle.................................................

Free download pdf