Project tutorial
A Simple Reflex Game

A Simple Reflex Game © GPL3+

A fun game to test your reaction time!

  • 1,203 views
  • 0 comments
  • 6 respects

Components and supplies

Apps and online services

Ide web
Arduino IDE
Use this for Windows, Mac OS X, and Linux.

About this project

Once you have correctly created the circuit and uploaded the code, open your serial monitor. It will instruct you to press the button to start the game. Now, look at the LED. When it turns off, press the button as fast as you can. The monitor will tell you how long it took for you to press it. Repeat! Challenge your friends and family!

Code

Simple Reflex GameArduino
Copy and paste the code below into your Arduino Editor
int ledPin = 13;
int sensorPin1 = 2;
int long ranDelay = 0;
int sensorValue = 0;
float realTime;

void setup()
{
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  pinMode(sensorPin1, INPUT);
}

void loop(){
  Serial.println("");
  Serial.println("");
  Serial.println("");
  Serial.println("Push the button to start game");
  
  while (digitalRead(sensorPin1)== 0) {
  }
  Serial.println("");
  Serial.println("");
  Serial.println("");
  Serial.println("Get Ready!");
  delay(1000);
  Serial.println("Get Set!");
  delay(1000);
  ranDelay = random(5000);
  delay(ranDelay);
  Serial.println("Go!");
  
  realTime = millis();
  digitalWrite(ledPin, HIGH);
 
  
  while (digitalRead(sensorPin1)== 0) {
    
  }
  digitalWrite(ledPin, LOW);
  Serial.println("Your time was");
  realTime = millis()-realTime;
  Serial.print(realTime/1000,2);
  Serial.println(" seconds");
 delay(2000); 
}

Schematics

Circuit Diagram
Reflex game led b2n8rlxtly

Comments

Similar projects you might like

Arduino Simple "Camera Slider" Electronics

Project tutorial by Ian Cumming

  • 8,424 views
  • 3 comments
  • 20 respects

Breadboard to PCB Part 1 - Making the Simon Says Game

Project tutorial by Katie Kristoff and Monica Houston

  • 8,190 views
  • 11 comments
  • 30 respects

Simple Programmable Robotic Arm

Project showcase by Ryan Chan

  • 92,691 views
  • 88 comments
  • 243 respects

Arduino Game By LCD

Project tutorial by Mohammed Magdy

  • 57,846 views
  • 53 comments
  • 183 respects

Arduino Controlled LED Multi-Player Game on Arduino "Shield"

Project tutorial by 22warehamD

  • 2,165 views
  • 2 comments
  • 10 respects
Add projectSign up / Login