Arduino_Scuola
Published © CC BY-NC-SA

Reaction Timer

Test your ability with the Reaction Timer!

IntermediateFull instructions provided30 minutes8,432
Reaction Timer

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Breadboard 830 points with Wire Kit
×1
5 PushButton 6x6
×1
10 10K potentiometers
×1
10 10K potentiometers
×1
Resistor 220 ohm
Resistor 220 ohm
×1
buzzer
×1

Story

Read more

Code

Code snippet #1

Arduino
/*
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);
}

Credits

Arduino_Scuola

Arduino_Scuola

32 projects • 155 followers

Comments