Project tutorial
Reaction Timer

Reaction Timer © CC BY-NC-SA

Test your ability with the Reaction Timer!

  • 3,487 views
  • 1 comment
  • 2 respects

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
×1
Breadboard 830 points with Wire Kit
×1
5 PushButton 6x6
×1
10 10K potentiometers
×1
10 10K potentiometers
×1
4415447 jg5sklyzsj
Resistor 220 ohm
×1
buzzer
×1

About this project

1. Before you start

This lesson will use a LCD this is the reason why you are invited to read  the lesson Arduino & LCDs before you start.

2. Schematic

The schematic is very simple. There are all the connections needed to use the LCD and three buttons that from left to right are UP, DOWN and START/STOP.

3. How does it work?

When the Arduino is powered on you'll be invited to set a countdown. Use the UP and DOWN button to choose the count and the START/STOP button to choose it. After a countdown will start and when the GO signal will appear on the screen you have to press the START/STOP button as soon as possible.

In base of your score a different message will appear on the screen:

  • Well done! if 0 < elapsed <= 350;
  • Not bad! if 350 < elapsed <= 500;
  • Try again please otherwise;

4. The code

Here is the code:

/*
Test your ability with the Reaction Timer
 author: Arturo Guadalupi 
 */
 
// include the library code:
#include 
 
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
 
int count = 0;
 
void setup() {
  lcd.begin(16, 2);
  pinMode(10, OUTPUT);
  pinMode(A0, INPUT); //UP button
  pinMode(A1, INPUT); //DOWN button
  pinMode(A2, INPUT); //START/STOP button
  
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Arduino");
  lcd.setCursor(0, 1);
  lcd.print("Reaction Timer!");
  delay(2000);
  lcd.clear();
  delay(1000);
}
 
void loop() {
  SetCountdown(); //function to set the countdown
  countdown();    //function for the countdown
  reaction();     //function who count your reaction
}
 
void SetCountdown()
{
  lcd.clear();
  lcd.print("Please set the");
  lcd.setCursor(0, 1);
  lcd.print("countdown");
  delay(2000);
  lcd.clear();
  
  while (digitalRead(A2) != LOW) //while you not press START
  {
    if (digitalRead(A0) == LOW) //if UP is pressed
    {
      count++;
      delay(200);
      lcd.clear(); 
    }
    if (count > 10) //10 seconds are enough to prepare yourself!
      count = 0;
 
    if (digitalRead(A1) == LOW) //if DOWN is pressed
    {
      count--;
      delay(200);
      lcd.clear(); 
    }
    
    if (count  350 && elapsed  500)
    lcd.print("Try again please");
  delay(1500);
}
 

Code

Code snippet #1Arduino
/*
Test your ability with the Reaction Timer
 */

// include the library code:
#include 

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int count = 0;

void setup() {
  lcd.begin(16, 2);
  pinMode(10, OUTPUT);
  pinMode(A0, INPUT); //UP button
  pinMode(A1, INPUT); //DOWN button
  pinMode(A2, INPUT); //START/STOP button
  
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Arduino");
  lcd.setCursor(0, 1);
  lcd.print("Reaction Timer!");
  delay(2000);
  lcd.clear();
  delay(1000);
}

void loop() {
  SetCountdown(); //function to set the countdown
  countdown();    //function for the countdown
  reaction();     //function who count your reaction
}

void SetCountdown()
{
  lcd.clear();
  lcd.print("Please set the");
  lcd.setCursor(0, 1);
  lcd.print("countdown");
  delay(2000);
  lcd.clear();
  
  while (digitalRead(A2) != LOW) //while you not press START
  {
    if (digitalRead(A0) == LOW) //if UP is pressed
    {
      count++;
      delay(200);
      lcd.clear(); 
    }
    if (count > 10) //10 seconds are enough to prepare yourself!
      count = 0;

    if (digitalRead(A1) == LOW) //if DOWN is pressed
    {
      count--;
      delay(200);
      lcd.clear(); 
    }
    
    if (count  350 && elapsed  500)
    lcd.print("Try again please");
  delay(1500);
}

Comments

Similar projects you might like

Arduino Kitchen Timer

Project tutorial by Team I and myself

  • 54,451 views
  • 37 comments
  • 77 respects

Measure your reaction time

Project tutorial by Jayraj Desai

  • 28,798 views
  • 9 comments
  • 29 respects

Arduino Mutitasking: Clock + Stopwatch + Timer

Project tutorial by LAGSILVA

  • 6,862 views
  • 10 comments
  • 43 respects

Alarm Clock and Timer Working Standalone

Project showcase by ozyRonald

  • 5,617 views
  • 6 comments
  • 10 respects

More than an Hour Timer

Project tutorial by Ian Cumming

  • 2,824 views
  • 1 comment
  • 4 respects

GymGeneral - A Sports Interval Timer

Project tutorial by Mr_Glenn

  • 1,718 views
  • 0 comments
  • 4 respects
Add projectSign up / Login