0% found this document useful (0 votes)
140 views3 pages

DIY Reaction Timer

This document provides instructions for building a DIY reaction timer using an Arduino microcontroller. It describes how the circuit works by having the Arduino turn on an LED and measure the time it takes the user to press a button in response. The example code prints the reaction times to the serial monitor for multiple trials. It also suggests experiments to analyze reaction time data and ways to expand the project by adding a buzzer.

Uploaded by

Harsh Shukla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
140 views3 pages

DIY Reaction Timer

This document provides instructions for building a DIY reaction timer using an Arduino microcontroller. It describes how the circuit works by having the Arduino turn on an LED and measure the time it takes the user to press a button in response. The example code prints the reaction times to the serial monitor for multiple trials. It also suggests experiments to analyze reaction time data and ways to expand the project by adding a buzzer.

Uploaded by

Harsh Shukla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Name:_______________________________Date:___________

DIYReactionTimer

Introduction
Mentalchronometry
isthestudyofhowfasthumansreacttodifferentinputs.Ittakesafewhundred
millisecondsforthesignaltogetfromyoureyes,toyourbrain,outtoyourlimbstorespond.Thereaction
timerisagreatprojecttodemonstratethistimedelay.Italsomakesforafungamebetweenfriends!

AccordingtotheteamatHumanBenchmark1,theaveragehumanreactiontimeisabout215ms.Howfast
areyou?

Theprincipalofthereactiontimerissimple:whentheuserseesthelightturnon,pressthebutton!A
microcontrollerisperfectforthisbecauseitcantimemillisecondsveryaccurately

Forthisproject,wewilluseanArduinotobethetime-keeper.AnArduinoisasmall,low-cost,andfast
microcontrollerthatiscapableofperformingcommand/instructionsatarateof16MHzorroughly62.5ns
perinstruction.

Wiring/HookupGuide(Fritzing)

http://www.humanbenchmark.com/tests/reactiontime/index.php
learn.
sparkfun
.com

Thewiringforthiscircuitissimple,itrequiresasingleLEDandasinglebutton.ConnecttheLEDbetween
pin12andGNDusingthesolderlessbreadboard.Rememberthateachrowof5holesareconnected
togetherbyaninternalmetalclip.MakesurethattheLEDlegandtheconnectingwireareinthesamerow.
Also,LEDshaveapolarity.MakesurethattheshortlegoftheLEDisconnectedtoGND.

Similarly,connectthebuttonupbetweenpins7andGND.

ExampleCode
https://codebender.cc/sketch:62303
/********************************************************************
*ReactionTimerSerialMonitor
*
*Hardwareconnections:
*LED:Pin12
*Button:Pin7
*
*Uploadthisexample,openuptheserialmonitorsetto9600bps.
*Pushthebuttonassoonasthelightturnon.
*******************************************************************/

intsound=false//enablesthebuzzer

/*Pinoutdefinitions*/
intledPin=12//connectLEDbetweenpin12andGND
intbuttonPin=7//connectpushbuttonbetweenpin7andGND
intgameNum=0//counterforthegamesplayed

unsignedlongwaitTime//Random"waiting"timebeforeturningonthelight
unsignedlongzeroTime//Zeroreferencetime
unsignedlongreactTime//ReactionTime

voidsetup()
{
Serial.begin(9600)//setupsupcommunicationtotalkbacktothecomputer

pinMode(ledPin,OUTPUT)//setsuptheledPintobeanOUTPUT
pinMode(buttonPin,INPUT_PULLUP)//Setsthepullupresistorforthebutton
digitalWrite(ledPin,LOW)//setspinLOW(GND)
//printsouttheheader.
Serial.print("Iter")
Serial.print("\t")
Serial.print("React(ms)")
Serial.println()
Serial.print("==============")
Serial.println()
}

voidloop()
{
randomSeed(analogRead(A5))//Getnoisetoseedtherandomnumbergenerator
//Useanunusedpinfortherandomnoise.
waitTime=random(2000,3500)//randomTimefrom2to3.5seconds
delay(waitTime)//delayrandomTime
digitalWrite(ledPin,HIGH)//turnonLED!

zeroTime=millis()//setzeroTimereference

while(digitalRead(buttonPin)==HIGH)//holdingloopuntilbuttonispressed.
{
}

learn.
sparkfun
.com


reactTime=millis()zeroTime//calculationofreactiontime

digitalWrite(ledPin,LOW)//turnoffLED!

//DisplayinformationtoSerialMonitor//

Serial.print(gameNum)
Serial.print("\t")
Serial.print(reactTime,1)
Serial.println()
delay(1000)//shortdelaybeforestartingagain.
gameNum++
}

AfteruploadingthiscodetoyourArduino,openuptheSerialMonitor.
WhentheLEDturnson,pressthebuttonasfastasyoucan.You
shouldseeyourdataresultsshowupintheterminalwindow.Thisis
textthattheArduinoisprinting/sendingbacktothecomputerfor
display.

Labs/Examples/InvestigationIdeas
Younowhaveareactiontimer.Great,nowwhat?Hereareafewideas
ofthingstoexplore:

Statistics:
Whatisyourfastestreactiontime?
Whatisyourslowestreactiontime?
Whatisthebestmeasureofyouractualreactiontime?(Measuresofcentraltendancy--
mean,median,mode)
Howdoyouidentifyanoutlier?Whatdoesstandarddeviationmean?
Bio/Social/OtherScience:
Doesreactiontimevarywithage?
Doesreactiontimevarywithdominantvs.non-dominanthand?
Doesthecolorofthelightmakeadifference?
Domalesvs.femaleshaveadifferenceinreactiontime?
InternalClock.Howgoodisyours?Howwellcanyouestimate5seconds?Howabout30
seconds?

GoingFurther
Seeifyoucanaddsoundtoyourreactiontimer.Youllneedabuzzerandafewextralinesofcode.
Connectupabuzzerbetweenpins9andGND.

Inthe
setup()
,addalinethatreads:
pinMode(9,OUTPUT)

And,tomakeatone,usethecommand:
tone(9,440)//9indicatestheOUTPUTpin,and440isthefrequency

Tostopthetone,usethiscommand:
noTone(9)

learn.
sparkfun
.com

You might also like