Fade an LED with a knob.
This basic circuit will let you use a knob to control the brightness of an LED. We will be using a potentiometer as our knob. The
potentiometer will output a voltage somewhere between 0 volts (ground) and 5v (source voltage). The Arduino will read this
voltage and use that value to set the brightness of the LED.
A note about LEDs: They don't really fade well. What I mean is that if you try to control the brightness of an LED by simply
reducing current, the LED will get somewhat less bright. But eventually, the LED simply shuts off. In order to get good fade
control, we use an ability of the Arduino board called Pulse-Width Modulation or PWM. When you use PWM it means that the
output is at full voltage, but it simulates lower voltages by pulsing the voltage at different rates. Notice that only certain digital pins
can be enabled for PWM -- on Arduino Duemilanove, it's pins numbered 3, 5, 6, 9, 10, 11.
Parts List
•
LED
•
potentiometer
•
Arduino (in this example, Duemillanove)
Assembly Steps
•
Connect the ground port on the Arduino board to one of the long rows of holes on the breadboard -- this makes that row
ground (0v).
•
Connect the 5v port on the Arduino board to one of the other rows of holes on the breadboard -- this makes that row
source voltage (5v).
•
Connect one of the outer two legs of the potentiometer to ground (negative), and connect the other outer leg to 5v
supply (positive).
•
Connect the center leg of the potentiometer to analog pin 0 on the Arduino board.
•
Connect the cathode (negative) leg of the LED to ground, and connect the anode (positive) leg of the LED to digital pin 9
on the Arduino board.
Image developed using Fritzing.