Stop It! LED game sphere **URGENT**

Hi, I am working on a project for my class that is a led game consisting of 8 LED’s (4 blue, 3 RB, and 1 RGB)

The LED’s common is 3.3v, so all values must be set to LOW in order to activate the led.

I have a button on pin 2, which is GNDed unless pushed. (simple T/F setup through digital read)
The Red leds are all connected to pin 3
The Green LED is connected to pin 4
And blue LED 1- blue LED 8 are connected to Pins 5-12

The globe is 3d printed, and the led “tray” has 8 pie cuts. Each slot has an LED in it. the order goes as following

–RGB, B, RB, B, RB, B, RB, B-- < COLORS corresponding to my led #
– 1 , 2, 3 , 4, 5 , 6, 7 , 8-- <LED #

The game works by pressing the button. This will start the game (indicated by 3 blue flashes)
After the 3 flashes, the blue LEDs will begin to revolve around in a circle. If you hit the correct box, It will run a “winner” flash (2 green flashes) then proceed to level 2. Levels are an increase in speed by 10%. However if the player hits the wrong boxes (the other 7 boxes) the game will revert to a loosing flash (game over), and reset the game back to the start sequence.

The player must land on the RGB LED in order to win.

My problem is I am having a VERY hard time understanding how i can constantly check if the user pressed the wrong light. I am stuck and need to have this resolved ASAP as i will be unable to work on it over the weekend (going to maker faire).

I have wrote a code that is not working, and im unsure on how to move forward. Please rewrite the code or give me some suggestions. I can test the rewritten code to check on the globe.

At the moment, the game is making absurd patterns that have no relation to what it is supposed to do…

Here is the code

int ledPins[] = {5,6,7,8,9,10,11,12}; 
int delayTime = 250; // Starting Led Speed
int level = 1; // Start at Level 1
int red = 3;
int button = 2;
int gameOver = 0;
int greenLed = 0; // Boolean to define when greenLed is on
int winner = 0;
void setup() 
 {           
   pinMode(2, INPUT); //button
   for(int i=5; i<13; i++)
   {
     pinMode(ledPins[i], OUTPUT);
   }
   
  
   
 }
 
 
 

void loop()
 {
   int buttonState = digitalRead(button);
   //
   //
   // start of game start flash
   for(int i=5; i<13; i++)
   {
     digitalWrite(ledPins[i],LOW);
     delay(200);
     digitalWrite(ledPins[i],HIGH);
     delay(200);
     digitalWrite(ledPins[i],LOW);
     delay(200);
     digitalWrite(ledPins[i],HIGH);
     delay(200);
     digitalWrite(ledPins[i],LOW);
     delay(200);
     digitalWrite(ledPins[i],HIGH);
   } 
   // end of game start flash
   //
   
   level = 1; // Reset Level to 1
   delayTime = 250; // Starting delay time
   gameOver = 0; // Set Game Over to false
    delay(500);
   //  preparing for game 
   //
   //  start of game sequence
   if(buttonState == 0)
    {
    digitalWrite(5,LOW);
    delay(delayTime);
    }
   else
   {
    digitalWrite(5,HIGH);
    int winner = 1;
   }
    //////
   if(buttonState == 0)
    {
    digitalWrite(6,LOW);
    delay(delayTime);
    }
   else
   {
    digitalWrite(6,HIGH);
    int gameOver = 1;
   }
    //////
   if(buttonState == 0)
    {
    digitalWrite(7,LOW);
    delay(delayTime);
    }
   else
   {
    digitalWrite(7,HIGH);
    int gameOver = 1;
   }
    //////
   if(buttonState == 0)
    {
    digitalWrite(8,LOW);
    delay(delayTime);
    }
   else
   {
    digitalWrite(8,HIGH);
    int gameOver = 1;
   }
    //////
   if(buttonState == 0)
    {
    digitalWrite(9,LOW);
    delay(delayTime);
    }
   else
   {
    digitalWrite(9,HIGH);
    int gameOver = 1;
   }
    //////
   if(buttonState == 0)
    {
    digitalWrite(10,LOW);
    delay(delayTime);
    }
   else
   {
    digitalWrite(10,HIGH);
    int gameOver = 1;
   }
    //////
   if(buttonState == 0)
    {
    digitalWrite(11,LOW);
    delay(delayTime);
    }
   else
   {
    digitalWrite(11,HIGH);
    int gameOver = 1;
   }
    //////
    if(buttonState == 0)
    {
    digitalWrite(12,LOW);
    delay(delayTime);
    }
   else
   {
    digitalWrite(12,HIGH);
    int gameOver = 1;
   }
    //////
   // end of game sequence
   //
   //
   // start of win/lose sequence
   if(winner == 1);
   {
    digitalWrite(greenLed,LOW);
    delay(delayTime);
    digitalWrite(greenLed,LOW);
    delay(delayTime);
   }
   
 if(gameOver == 1);
   {
    digitalWrite(red,LOW);
    delay(delayTime);
    digitalWrite(red,LOW);
    delay(delayTime);
   }
   // end of win/lose sequence
   //
}
//
//
//
//
void buttonPush()
{ 
  static unsigned long last_interrupt_time = 0;
  unsigned long interrupt_time = millis();
  if (interrupt_time - last_interrupt_time > 300)
   {
   if(winner == 1)
    { 
    delayTime = delayTime * 9 / 10; // Increase Delaytime by 10%
    level++; // Increase level by 1
    }
    else
    {
     gameOver = 1; // If greenLed is not true, it must be false, hence set Game Over as True
    }
    last_interrupt_time = interrupt_time;
  }
}

All help is useful! Thank you!

for(int i=5; i<13; i++);

Get rid of the ;

yup found that just after posting this :), the game still makes absolutely no sense about what it is doing when i uploaded the code though

You need to enable the internal pull up resistors on that push button pin 2.

The code is very badly structured and makes little sense. The start of the loop should not be the start of the game. You need to implement a state machine to structure your code.

I have a resistor between gnd and pin 2, 5v is on the other pole of the switch.

Do you mind giving me a demonstration on the code structure? I dont really understand state machines on arduino

Don't cross-post, other thread deleted.

  {
    digitalWrite(6,HIGH);
    int gameOver = 1;
   }

Which does what?

Do you mind giving me a demonstration on the code structure? I dont really understand state machines on arduino

See my http://www.thebox.myzen.co.uk/Tutorial/State_Machine.html Or Robin2's several things at once http://forum.arduino.cc/index.php?topic=223286.0

A good real example of the code structure you need is this project:- http://www.thebox.myzen.co.uk/Hardware/Dice_Game.html