ARDUINO
PROJECT – FADING LIGHT SHOW

 

 

LESSONS

 

You should have looked at all lessons up to and including Lesson 8 before starting this project.

 

DESCRIPTION

 

In this project, you will make use of analogWrite(), if statements and randomness to create a light show consisting of 4 LEDs.  The LEDs will fade up and down going from 0 to 255 to 0 continuously.  However, the LEDs will also be given random values to start at and a random direction (going up or going down).  So each time you watch your light show, it will be different.

 

PSEUDOCODE

 

Here is the pseudocode:


GLOBAL VARIABLES

1-Create global variables representing the pin number used for each LED.  Remember that you need to use pins that can do Pulse Width Modulation.

 

2-Create global variables representing the voltageNumber for each LED.

3-Create global variables that keep track if an LED is fading in or out.  This can be an integer that is either -1 or 1 or some other way.

 

SETUP()

 

1-Set all of the required pins as OUTPUT pins.

2-Give each of the voltageNumber variables a random number between 0 and 255.

 

3-Give each of the direction variables a random value that states whether you are fading in or out.

 

LOOP()

 

1-Repeat the following for each LED

 

A-Update voltageNumber (increase or decrease it by 1).

B-Use analogWrite to update the LED’s brightness.

C-If voltageNumber has reached 0 or 255, the direction variable needs to change so that we switch directions next time.

 

2-At the very end, add a short delay so that we can see the fading happen. Use whatever you think works best.

 

 

PROJECT EXPECTATIONS

 

Create the fading light show circuit described above.  Show it to Mr. Campeau.