Reaction timer using arduino

Discussion in 'Programmer's Corner' started by new user, Aug 5, 2013.

  1. new user

    Thread Starter New Member

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



    Code ( (Unknown Language)):
    1.  
    2. void setup()
    3. {
    4.   //start the serial
    5.   Serial.begin(9600) ;
    6.  
    7.   //LED output
    8.   pinMode (13, OUTPUT) ;
    9.   //Switch input
    10.   pinMode (8, INPUT) ;
    11.  
    12.   //set the random number generator
    13.   randomSeed (millis()) ;
    14.  
    15.   //Wait random time from 1 to 3 seconds
    16.   delay (3000) ;
    17.  
    18.   //turn the light on
    19.   digitalWrite (13, HIGH) ;
    20.   //get the start time
    21.   long start = millis() ;
    22.  
    23.   //wait while the switch isn't pressed
    24.   while (digitalRead(8))
    25.   {
    26.   }
    27.   //print out the data
    28.   Serial.print ("Your reaction time: ") ;
    29.   Serial.println ((millis() - start) / 1000.0) ;
    30. }
    31.  
    32. void loop ()
    33. {
    34. }
    35.  
     
    Last edited by a moderator: Aug 6, 2013
  2. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,809
    834
    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!
     
  3. bertus

    Administrator

    Apr 5, 2008
    15,648
    2,347
Loading...