ARDUINO
PROJECT – 4-LED LIGHT SHOW
PROJECT
DESCRIPTION
You will create a 4-LED light show as described below.
LESSONS
You should have looked at all lessons up to and including Lesson 5 before
starting this project.
CONTROLLING
MULTIPLE LEDs
One can easily create a light show style project with the Arduino. We simply connect the positive side of each
LED to a pin on the Arduino. The negative side of each LED goes to a resistor
and then to ground.
PSEUDOCODE
Pseudocode is simply a
program that is written in English instead of in the correct syntax. It allows to explain how to create a program
without giving every detail.
Here is the pseudocode for programs that control several LEDs to create a
light show:
1-Create global variables representing the pin number used for each
LED. 2-Inside setup(), set all of the used pins as OUTPUT pins. 3-Inside loop(), do the following: A-Set the appropriate
pins to HIGH / LOW to create the first pattern. B-Delay C-Repeat steps 3A &
3B for each pattern to follow. |
PIN
LIMIT
For larger light shows, one concern that arises is that the Arduino only
has 13 pins to use to control LEDs. This
means that an innovative solution is required to handle more than 13 LEDs. We won’t look at this now.
WARNING
An LED always has to be in series with a resistor. The LED and the Arduino can be damaged
if you do not have a resistor.
PROJECT
EXPECTATIONS
For this first independent project, you will create the circuit on the
breadboard and Arduino and show Mr. Campeau before powering the Arduino.
Create a circuit that has four LEDs (and 4 resistors). Write the program that will make the LEDs
turn on and off following one of the patterns below. Note that there should be 1 second delay
between different pattern states.
Pattern Type |
Mark |
Description |
State Truth Table (Four LEDs) |
a) Ring Counter |
8/10 |
The first LED is on for 1 second.
Then the 2nd is on for 1 second. Then the third. Then the fourth. Restart. |
1000 0100 0010 0001 |
b) Twisted Ring
Counter |
9/10 |
No LEDs are on. Then first LED
is on for 1 second. Then the first two
are on for the next second. Then the first three. Then all LEDs are on. Then the last three. Then the last two. Then the last one. Then none.
Restart. |
0000 1000 1100 1110 1111 0111 0011 0001 |
c) Binary
Counter |
10/10 |
First, the binary value of zero is displayed. Then, the binary value of one. Then, of two. Then, three. And so on until 15. Then it restarts at zero. |
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 |