Reaction timer using arduino

Thread Starter

new user

Joined Aug 5, 2013
1
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:

djsfantasi

Joined Apr 11, 2010
9,156
You have revived a post that was more than 2 years old. We refer to this as necroposting, as you are attempting to raise a post from the dead. In addition, your question is not related to the original one; this is referred to as hijacking. Both are considered to be in poor taste. You should start your own thread, by clicking on the "New Thread" button near the top of the page.

Good luck!
 
Top