Hello!
Some time ago I made a roulette led to some friends who own a cafe.
The initial idea was when the roulette stoped randomly in one of 12 LEDs, depending on color, the beer could be free, regular price or twice the normal price.
The code and the final product worked very well and, even today, are still used.
However, in conversation, we decided to make an extra cover to be able to switch between the game of beer and a new game of shot's.
The game consists of 12 different shots, one for each LED. The problem is that we need that when the wheel is spinning normally, if we click on one of the two buttons that we'll add, she has to stop random but obligatorily a set of 4 LEDs.
I am new at this and don't have the slightest idea what to do.
Can anyone help?
thank you
here's my code:
int led[12] = {41,40,39,38,37,36,35,34,33,32,31,30};
int del = 50; //delay
int aktuell = 0;
int zufall;
const int btnVodkaGroup = 11;
const int btnWhiskyGroup = 10;
int resetPin = 12;
int buttonState = 0;
int buttonState1 = 0;
int buttonState2 = 0;
void setup(){
pinMode(btnVodkaGroup, INPUT);
pinMode(btnWhiskyGroup, INPUT);
for(int i = 0;i <= 11;i++){
pinMode(led[i], OUTPUT);
}
randomSeed(analogRead(0));
zufall = random(190, 210);
}
void(* resetFunc) (void) = 0;
void loop(){
buttonState = digitalRead(resetPin);
if (buttonState == HIGH)
resetFunc(); }
normal();
}
void normal()
{ for(int i = 0;i <= 11;i++){
if (del <= zufall)
{
laufen(i);
}
else
{
digitalWrite(led[aktuell], HIGH);
}
}
}
void laufen(int i){
digitalWrite(led[i], HIGH);
delay(del);
digitalWrite(led[i], LOW);
del+=2;
aktuell = i;
}
roullete.txt (944 Bytes)