Arduino LED Reflex Game - Test Your Reaction Speed!

by 900006 in Circuits > Arduino

9 Views, 0 Favorites, 0 Comments

Arduino LED Reflex Game - Test Your Reaction Speed!

Screenshot 2025-06-17 1.18.30 PM.png
Screenshot 2025-06-17 1.21.28 PM.png

The goal of this project is to create an interactive LED Reflex Game using an Arduino. The game lights up LEDs in sequence, and the player must press a button when the red LED lights up. If the button is pressed in time, the buzzer beeps and the player scores a point. This game challenges your reaction time and is fun and easy to play. It uses simple components and basic coding but allows for customization and enhancements. Perfect for beginners aiming for an A+ project.

Supplies

Screenshot 2025-06-17 1.31.06 PM.png
Screenshot 2025-06-17 1.32.04 PM.png
Screenshot 2025-06-17 1.33.53 PM.png
Screenshot 2025-06-17 1.34.32 PM.png
Screenshot 2025-06-17 1.35.03 PM.png
Screenshot 2025-06-17 1.35.52 PM.png
Screenshot 2025-06-17 1.41.13 PM.png
Screenshot 2025-06-17 1.42.50 PM.png
Screenshot 2025-06-17 1.43.18 PM.png

Components Needed:

  1. Arduino UNO or compatible board
  2. Breadboard
  3. 12 LEDs (11 green, 1 red)
  4. 12 resistors (220Ω) or (330Ω)
  5. 1 push button
  6. 1 piezo buzzer
  7. Jumper wires/ Jumpers

Place LEDs

Screenshot 2025-06-17 1.46.55 PM.png

Start by placing all 12 LEDs on the breadboard. First 5 green LEDs, and then one red LED, and then the remaining 6 green LEDs.

Place Resistors (220Ω) or (330Ω)

Screenshot 2025-06-17 1.52.37 PM.png

Connect the cathode that is a short led of each LED to one end of (220Ω) or (330Ω) resistor. Connect the other end of the resistor to the negative rail of the breadboard.

Arduino Pins

Screenshot 2025-06-17 2.00.01 PM.png

Now where the LED anodes the long lead to the Arduino pins. First five green LEDs to digital pin D2, D3, D4, D5, and D6. And then the anode of red LED to pin D7. Then connect the remaining anodes od green LEDs to pin D9, D9, D10, D11, and D12 in proper sequence.

Push Button

Screenshot 2025-06-17 2.07.51 PM.png

Next, place the push button on the breadboard. Connect one leg of the button to the negative rail. Connect the other leg to analog pin A1.

Buzzer

Screenshot 2025-06-17 2.11.43 PM.png

And now for the buzzer. Connect the negative leg to the negative rail and the positive leg to analog pin A2.

Connect Ground

Screenshot 2025-06-17 2.14.47 PM.png

Finally connect the G&D of Arduino to the negative rail.

Check Connection

Screenshot 2025-06-17 2.16.55 PM.png

Double check the connection with he circuit diagram to avoid short circuits.

Code Timeeee!

Screenshot 2025-06-17 2.20.26 PM.png

Here is the code:

// Define pin numbers

const int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};

const int redLedPin = 7; // Among them pin 7 is red LED. That's our target LED.

const int buttonPin = A1; // We also set up the push button on analog pin A1

const int buzzerPin = A2; // The buzzer is on A2


int totalLeds = 12;

int currentLed = 0;

bool gamePaused = false;

// We're keeping track of the total number of LEDs, current active LED and whether the game is paused or not.


void setup() {

// Set all LED pins as OUTPUT

for (int i = 0; i < totalLeds; i++) {

pinMode(ledPins[i], OUTPUT);

}


pinMode(buttonPin, INPUT_PULLUP); // use internal pull-up resistor

pinMode(buzzerPin, OUTPUT);


// Turn off all LEDs and buzzer

turnOffAllLeds();

digitalWrite(buzzerPin, LOW);

}

// In the setup function, we set all the LED pins as output. The push button is set as a input_pullup to use as Arduino's internal resistor. The buzzer is set to output. Then we turn off all LEDs and mute the buzzer initially.


void loop() {

if (!gamePaused) {

// Turn off all LEDs

turnOffAllLeds();

// Turn on current LED

digitalWrite(ledPins[currentLed], HIGH);

delay(100); // Adjust scrolling speed here

// The loop function keeps the game running. If the game is not paused, it's turn off all LEDs. Then it lights up the Current LED, wait for 100 milliseconds and then control the speed of the scrolling light.


// Check for button press

if (digitalRead(buttonPin) == LOW) {

gamePaused = true;

delay(200); // simple debounce

checkResult();

}

// If the button is pressed, the game is paused and it checks whether the player stopped at the red LED.


// Move to next LED

// Finally, it moves the current LED to the next one in the list and loops again.

currentLed = (currentLed + 1) % totalLeds;

}

}


void checkResult() {

if (ledPins[currentLed] == redLedPin) {

// Correct stop

happyBeep();

} else {

// Wrong stop

sadBeep();

}


delay(2000); // Wait before restarting game

gamePaused = false;

}


void happyBeep() {

tone(buzzerPin, 1000, 200); // High tone

delay(300);

tone(buzzerPin, 1500, 200); // Higher tone

delay(300);

noTone(buzzerPin);

}


void sadBeep() {

tone(buzzerPin, 400, 400); // Low tone

delay(500);

noTone(buzzerPin);

}


void turnOffAllLeds() {

for (int i = 0; i < totalLeds; i++) {

digitalWrite(ledPins[i], LOW);

}

}

Connect to Computer & Play!

Screenshot 2025-06-17 2.24.27 PM.png
Screenshot 2025-06-17 2.24.47 PM.png
Screenshot 2025-06-17 2.25.08 PM.png

Now upload the code to the Arduino. Connect the Arduino UNO to your computer using the USB cable for uploading the code. Select port and board in the same menu and select Arduino UNO. Now clock on the upload button. Once uploaded, Power your Arduino. The LEDs light up one by one in sequence like a chaser. The red LED is a target LED. When you press the button exactly when the red LED lights up, you win. If you press it at the wrong time, the buzzer gives you a sad tone. A successful press triggers a happy double beat.

Will you get the happy beat or the sad buzz?