Hi everybody,
im new to the forums and the arduino scene, still finding my feet but having a blast learning and modifying at each step.
The Project
To build an electronic roulette style LED setup (i have this part complete) that when the light stops on a random LED, a relay that corresponds to that particular LED will trigger (this i need some guidance with)
So, it consists of
4 lights, hooked up to an Arduino Uno on pins 5,8,11 and 13
A push button momentary switch is setup on pin 2
Here is my current setup on a solderless breadboard
apologies if this is wrong, still starting out on drawing the diagrams, that is how im seeing it on the board
and here's the code
/*
random light
*/
const int buttonPin = 2;
int lightpins[4] = {5,8,11,13};
int state=0;
void setup()
{
pinMode (buttonPin,INPUT);
pinMode (lightpins[0],OUTPUT);
pinMode (lightpins[1],OUTPUT);
pinMode (lightpins[2],OUTPUT);
pinMode (lightpins[3],OUTPUT);
digitalWrite (lightpins[0],LOW);
digitalWrite (lightpins[1],LOW);
digitalWrite (lightpins[2],LOW);
digitalWrite (lightpins[3],LOW);
}
void loop ()
{
int reading = digitalRead (buttonPin);
int blinktime=50;
boolean done;
if (reading == HIGH)
{
if (state==0)
{
state=1;
done=false;
blinktime=20;
blinktime += random(22);
while (!done)
{
for (int j=0;j<4;j++)
{
blinktime += 4;
digitalWrite(lightpins[j],HIGH);
if (blinktime>200)
{
done=true;
break;
}
delay(blinktime);
digitalWrite(lightpins[j],LOW);
delay(blinktime);
}
}
}
}
else
{
state=0;
}
}
original code from here (i've just modified a few parts)
http://arts-4510-f11.wp.rpi.edu/2011/09/28/arduino-led-roulette/
how do i go about adding in a relay to each LED, and only having it trigger once the sequence ends?
any help would be immensely appreciated,
cheers
Dan