**Arduino Control of LED Display with timing and 4 switches**
We have a display that is lit with LED's and fiber optics. We would like to control the LED's with an arduino duemilanove micocontroller. The electronics and display are done but we need the core of the Arduino programming done.
The code is not tremendously difficult but I would like it to be modular so that we can easilly modify it for the customer. Basically 4 buttons put the display into one of 4 possible states that make the LED's flash in different sequences. Long button pushes are differentiated from short button pushes.
Deliverable is an Arduino "sketch" . No hardware. Ongoing support is probable.
Lead time is very short. Work must be completed no later than March 3. Prefer earlier.
## Deliverables
There are 4 switches in the display and 4 discrete LED's. The switches are discrete momentary push button type in a prototype membrane panel.
The LED's are powered by constant current drivers that have +0-5v digital inputs for switching.
The general concept is that the user can press one of the 4 buttons with a long press to select one of 4 programs. When the selected program is running, a short press on any of the 4 switches will control the LED action within that program. A longpress on the button that corresponds to the currently running program will turn off that program and all LED's will be dark. A long press on any other button will change to that program instead of the current. The LED's can either be On, flashing in one of two speeds, or off.
In this V1 implementation only program 1 is interactive. In other words, only program 1 implements the short button pushes to provide manual control. The other 3 programs are fairly easy and are just display loops with the LED's in various states.
I have written the following pseudo code:
**Variables**
\\Button press times\\
Longpresstime (default >1 sec)
shortpresstime (default <1 sec)
\\slowflash consists of \\
Flashontime (default 1sec)
Flashofftime ( default 1sec)
\\fastflash consists of\\
Flashfastofftime (default .2sec)
Flashfastontime (default .5sec)
\\plus of course other variables required\\
\\ Programs -- includes or spagettii code ok\\
\\-Program 1 Manual Mode
-Program 2 Flash All
-Program 3 Demo Mode
-Program 4 Accident Mode
plus the Container or Master program\\
**\\Master Program \\**
If Longpress on sw1 then program 1
If Longpress on SW2 then program 2
If Longpress on sw3 then program 3
if longpress on sw4 then program 4
**\\Program1 interactive mode\\**
\\ each switch controls the corresponding LED toggling through 3 states, ON, FLASH and OFF\\
\\but first we check to see if we should exit this program\\
If longpress on SW1 then all off.
\\now check to see if the user wants to turn on LED's \\
If shortpress sw1 then white on
If shortpress sw1 again then white flashes slow
If shortpress sw1 again then white off
If shortpress SW2 then yellow on
If shortpress sw2 again then yellow flashes slow
if shortpress sw2 again then yellow off
If shortpress sw3 then green on
If shortpress sw3 again green flashes slow
If shortpress sw3 again then green off
If shortpress sw4 then red on
If shortpress sw4 again then red flashes slow
If shortpress sw4 again then red off.
**\\Program 2 Flash all \\**
\\but first we check to see if we should exit this program\\
If longpress on SW2 then all off else
Red flashes slow
Green flashes slow
White flashes slow
Yellow flashes slow.
**\\Program 3 Demo\\**
\\but first we check to see if we should exit this program\\
If longpress on SW3 then all off else
Demo mode.
Turn on White
wait 2 sec
Turn on yellow
wait 2 seconds
Flash green 3 times
Turn on green
wait 5 seconds
turn off green
wait 5 seconds
fast flash red 30 times
wait 10 seconds
turn all off
repeat
**\\Program 4 accident mode\\**
\\but first we check to see if we should exit this program\\
If Longpress on SW4 then all off else
Red flashes fast
Green On
White On
Yellow On