I need help with a game (Reaction game)

I have worked on a reaction game where two people will compete for who can press their button first when when the LED in the middle turns on .
If you press the button first when the LED in the middle turns on then you win! But if you press the button to early and the LED is not turned on then you losse and the other person wins. When you win, the LED on your side starts to blink very fast.

I have a problem!!!

Everything works as it should except that when you press the button too early nothing happens.
Because of this bug, you can just hold the button down before the LED in the middle is turned on and you will win automatically.

Here is the code:

void setup(){
  pinMode (2,OUTPUT);
  pinMode (3,INPUT);
  pinMode(13, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode (12,INPUT);
  
  
}


void loop() {
  
  digitalWrite( 2,LOW);
   while (digitalRead(3) == LOW and digitalRead(12) ==LOW){}

  if (digitalRead(3) == HIGH){
    digitalWrite(7, HIGH);
    delay(200);
    digitalWrite(7, LOW);
    delay(200);
    digitalWrite(7, HIGH);
    delay(200);
    digitalWrite(7, LOW);
    delay(200);
    digitalWrite(7, HIGH);
    delay(200);
    digitalWrite(7, LOW);
    delay(200);
return;
  }
  else{
    digitalWrite(13, HIGH);
    delay(200);
    digitalWrite(13, LOW);
    delay(200);
    digitalWrite(13, HIGH);
    delay(200);
    digitalWrite(13, LOW);
    delay(200);
    digitalWrite(13, HIGH);
    delay(200);
    digitalWrite(13, LOW);
    delay(200);
    return;
  } 
  
  delay(5000);
  digitalWrite( 2,HIGH);
  while (digitalRead(3) == LOW and digitalRead(12) ==LOW){}
 
  if (digitalRead(3) == HIGH){
     digitalWrite(13, HIGH);
    delay(200);
    digitalWrite(13, LOW);
    delay(200);
    digitalWrite(13, HIGH);
    delay(200);
    digitalWrite(13, LOW);
    delay(200);
    digitalWrite(13, HIGH);
    delay(200);
    digitalWrite(13, LOW);
    delay(200);
  }
  else{
    digitalWrite(7, HIGH);
    delay(200);
    digitalWrite(7, LOW);
    delay(200);
    digitalWrite(7, HIGH);
    delay(200);
    digitalWrite(7, LOW);
    delay(200);
    digitalWrite(7, HIGH);
    delay(200);
    digitalWrite(7, LOW);
    delay(200);
  
  }
}

And here is the circuit:

copy_of_copy_of_reaction_game1 (1).ino (1.46 KB)

In order to let your code make any sense, please use some defines or constants to describe your pins and re-post the code.

//Define
#define BUTTON1_PIN 5

//Const
const byte BUTTON1_PIN = 5;

I have definined the buttons but it dosen’t work!

//Define
#define BUTTON1_PIN 5
int Button1Pin = 12;
int Button2Pin = 3;

void setup(){
  pinMode (2,OUTPUT);
  pinMode (Button2Pin,INPUT);
  pinMode(13, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode (Button1Pin,INPUT);
  
  
}


void loop() {
  
  digitalWrite( 2,LOW);
   while (digitalRead(Button2Pin) == LOW and digitalRead(Button1Pin) ==LOW){}

  if (digitalRead(Button2Pin) == HIGH){
    digitalWrite(7, HIGH);
    delay(200);
    digitalWrite(7, LOW);
    delay(200);
    digitalWrite(7, HIGH);
    delay(200);
    digitalWrite(7, LOW);
    delay(200);
    digitalWrite(7, HIGH);
    delay(200);
    digitalWrite(7, LOW);
    delay(200);
return;
  }
  else{
    digitalWrite(13, HIGH);
    delay(200);
    digitalWrite(13, LOW);
    delay(200);
    digitalWrite(13, HIGH);
    delay(200);
    digitalWrite(13, LOW);
    delay(200);
    digitalWrite(13, HIGH);
    delay(200);
    digitalWrite(13, LOW);
    delay(200);
    return;
  } 
  
  delay(5000);
  digitalWrite( 2,HIGH);
  while (digitalRead(Button2Pin) == LOW and digitalRead(Button1Pin) ==LOW){}
 
  if (digitalRead(Button2Pin) == HIGH){
     digitalWrite(13, HIGH);
    delay(200);
    digitalWrite(13, LOW);
    delay(200);
    digitalWrite(13, HIGH);
    delay(200);
    digitalWrite(13, LOW);
    delay(200);
    digitalWrite(13, HIGH);
    delay(200);
    digitalWrite(13, LOW);
    delay(200);
  }
  else{
    digitalWrite(7, HIGH);
    delay(200);
    digitalWrite(7, LOW);
    delay(200);
    digitalWrite(7, HIGH);
    delay(200);
    digitalWrite(7, LOW);
    delay(200);
    digitalWrite(7, HIGH);
    delay(200);
    digitalWrite(7, LOW);
    delay(200);
  
  }
}

It would be useful to give the pins meaningful names.

The two outside LEDs need series dropping resistors.

Always show your actual wiring.

Post your images here not on IMGUR.

I have attached the circuit picture.

Down here!

I need help, i still dont understand!!!

You don’t understand why it is useful for you and for others to use meaningful pin names?

OP’s image.