React!-ion Time Device

by erio.arter in Circuits > Arduino

184 Views, 1 Favorites, 0 Comments

React!-ion Time Device

123778411_792614714618559_6739274831782669692_n.jpg

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

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

The Circuit

123657087_834311920713553_7141247340841975269_n.jpg

DISCLAIMER: I'm not experienced writing Circuits, so the picture might be misleading.

The Code

124024617_389709982440872_7385140076377655528_n.jpg
//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);
		}
	}
}

The Test

124153401_810458459688060_842048327216149243_n.jpg

You made it!

Now, let's test it.

  1. Hit the upload button in your Arduino software
  2. Press Ctrl + Shift + M (alternatively open Serial Monitor through Tools)
  3. 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.