LED roulette wheel, adding relays? coding and circuit help

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

Well you've drawn capacitors where there should be resistors (resistors are either rectangles (european style) or zig-zag lines).

For a relay driving circuit have a look here: Arduino Playground - HomePage (note the diode across the relay winding is vital)

For your purposes you can use another 4 digital pins to control the relays - you need to be able to separately control
the relay and its LED (otherwise you cannot have the LED on without the relay).

If you are going to be short of pins there are other ways to achieve this, but if you have only 4 LEDs and 4 relays there are
enough pins I hope.

What do the relays switch? Perhaps relays aren't necessary and transistors / darlington array or MOSFETs can be used instead?

Thanks for the help on this one, apologies for the diagram mix up, i assure you they are resistors on the board and not caps! just my diagram that indicated otherwise.\

The board im using has 13 pins total and im only using 5 so there are a few spare.

the relays will be switching 12v solenoid valves, for new kind of "russian roulette" style game (novelty game, no danger involved) for a group of friends.

If having the relay (or your other suggestions) trigger only at the end is to difficult, i have been tossing up going back to basics and using the blink project to code predetermined results, e.g push button, led's cycle through and it lands on 4, triggers a relay. push button, cycle again, land on 3, relay triggers etc and writing different outcomes in the code for up to 20 button pushes before looping back to the first outcome. i won't be playing it, but to them that would seem random enough. any thoughts?

thankyou again
Dan