Devices & Components
Arduino Uno Rev3
Breadboard 830 points with Wire Kit
Resistor 220 ohm
10 10K potentiometers
10 10K potentiometers
5 PushButton 6x6
Hardware & Tools
buzzer
Project description
Code
Code snippet #1
arduino
1/* 2Test your ability with the Reaction Timer 3 */ 4 5// include the library code: 6#include 7 8// initialize the library with the numbers of the interface pins 9LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 10 11int count = 0; 12 13void setup() { 14 lcd.begin(16, 2); 15 pinMode(10, OUTPUT); 16 pinMode(A0, INPUT); //UP button 17 pinMode(A1, INPUT); //DOWN button 18 pinMode(A2, INPUT); //START/STOP button 19 20 lcd.clear(); 21 lcd.setCursor(0, 0); 22 lcd.print("Arduino"); 23 lcd.setCursor(0, 1); 24 lcd.print("Reaction Timer!"); 25 delay(2000); 26 lcd.clear(); 27 delay(1000); 28} 29 30void loop() { 31 SetCountdown(); //function to set the countdown 32 countdown(); //function for the countdown 33 reaction(); //function who count your reaction 34} 35 36void SetCountdown() 37{ 38 lcd.clear(); 39 lcd.print("Please set the"); 40 lcd.setCursor(0, 1); 41 lcd.print("countdown"); 42 delay(2000); 43 lcd.clear(); 44 45 while (digitalRead(A2) != LOW) //while you not press START 46 { 47 if (digitalRead(A0) == LOW) //if UP is pressed 48 { 49 count++; 50 delay(200); 51 lcd.clear(); 52 } 53 if (count > 10) //10 seconds are enough to prepare yourself! 54 count = 0; 55 56 if (digitalRead(A1) == LOW) //if DOWN is pressed 57 { 58 count--; 59 delay(200); 60 lcd.clear(); 61 } 62 63 if (count 350 && elapsed 500) 64 lcd.print("Try again please"); 65 delay(1500); 66} 67
Comments
Only logged in users can leave comments