i am making a reaction timer using arduino eleven and every thing is working fine but then it is displaying the time that you got it contently keeps displaying 00.0 in the serial monitor. please help me the code that i used is below
Rich (BB code):
void setup()
{
//start the serial
Serial.begin(9600) ;
//LED output
pinMode (13, OUTPUT) ;
//Switch input
pinMode (8, INPUT) ;
//set the random number generator
randomSeed (millis()) ;
//Wait random time from 1 to 3 seconds
delay (3000) ;
//turn the light on
digitalWrite (13, HIGH) ;
//get the start time
long start = millis() ;
//wait while the switch isn't pressed
while (digitalRead(8))
{
}
//print out the data
Serial.print ("Your reaction time: ") ;
Serial.println ((millis() - start) / 1000.0) ;
}
void loop ()
{
}
Last edited by a moderator: