DIY Reaction Timer
DIY Reaction Timer
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