Introduction: React!-ion Time Device
Have you ever grabbed something thrown to you, five seconds after it passed you?
This Project is for both those who now have a banana in their hand and those who now have a banana on the floor.
This is a simple build with an even simpler code.
It tests your reaction time based on how fast you manage to push the button after a light turns on.
I'm assuming that no user reacts with the speed of light, so we're just going to say bye-bye to that constant for a while. If anyone wants to implement it into their project it's approximately C=3,00*10^8.
So, let's get started.
Supplies
- Arduino Uno (and the USB cable that follows)
- 1 LED
- 1 Button
- 1 10k ohm resistor
- 1 220 ohm resistor.
- 6 Jumper Wires
Step 1: Get the Components
Arduino Starter Kit: https://www.banggood.com/Basic-Starter-Kit-UNO-R3-...
This kit is relatively cheap and contains all the parts you need
Step 2: The Circuit
DISCLAIMER: I'm not experienced writing Circuits, so the picture might be misleading.
Step 3: The Code
//Declare the variables int Led = 7; int Button = 8; int val = 0; int Charge = 0; float theTime = 0: //Begin Serial communication with Serial Monitor and define INPUT/OUTPUT void setup () { Serial.begin(9600); pinMode(Led, OUTPUT); pinMode(Button, INPUT); } //The main code void loop () { if(digitalRead(Button) == 1){ val = random(5, 100); if(val == 20 && Charge == 0){ digitalWrite(Led, HIGH); Serial.println("Light has been turned on"); Charge++; } if(val == 20 && digitalRead(Button) == 1){ delay(1); theTime++; Serial.println(theTime); } if(digitalRead(Button) == 0){ theTime = theTime/100; Serial.println("You Spent " + String(theTime) + " Seconds."); delay(1000000000); } } }
Step 4: The Test
You made it!
Now, let's test it.
- Hit the upload button in your Arduino software
- Press Ctrl + Shift + M(alternatively open Serial Monitor through Tools)
- Press the button when the LED lights up.
Congrats! You can now see your reaction time! :)
If you have any problems with this project, please let me now in the comments.