This project uses a potentiometer to control the movement of light along a row of LEDs. As the light "moves" from one LED to the next, the LEDs next to it fade rather than dropping off. This makes the light appear to move back and forth fluidly.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Setting Up the Potentiometer
1.) Connect the power and ground rails on your breadboard to your Arduino
a. Connect a wire from the blue ground rail on your breadboard to a ground (GND) pin on your Arduino
b. Connect a wire from the red power rail on your breadboard to the 5 Volt (5V) pin on your Arduino
2.) Connect your potentiometer to the power rail, ground rail, and pin A5
a. Connect a wire from the red power rail on your breadboard to the top pin on your potentiometer
b. Connect a wire from the blue ground rail on your breadboard to the bottom pin on your potentiometer
c. Connect a wire from analog pin 5 (A5) on your Arduino to the middle pin on your potentiometer
Step 2: Setting Up the LEDs
1.) Connect 5 LEDs in a row to the Pulse Width Modulation (PWM) pins on the Arduino
a. Connect the longer pin (Anode)on the first LED to digital pin 11 on your Arduino
b. Connect the shorter pin (Cathode) on the first LED to the blue ground rail on your breadboard
c. Continue this pattern with 4 more LEDs using digital pins 10, 9, 6, and 3
Note: You must use the specified pins for the code to work, but it is also important to note that these pins are PWM pins as denoted by the "~" next to the pin number. If you do not use these pins your LEDs will not dim.
You may use 220 Ohm resistors for each LED, but I found that the different light levels are easier to tell apart without them, since they cause the brightest setting to look dimmer.
Step 3: Upload the Code
1.) Upload the provided code to your Arduino and try it out.
Turning the potentiometer clockwise should move the light right and turning it counterclockwise should move the light left. If this is reversed it is possible your potentiometer is made differently than mine. If you want it to work the same and it reversed, simply switch the location of the moveRight() and moveLeft() calls in the code.