Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. if (buttonState == LOW) {//Call Game function
  2.   tone(BUZZER,pitch);
  3.   delay(500);
  4.   noTone(BUZZER);
  5.   delay(2000); //Up to this point it works fine
  6.   for ( int i = 1 ; i <= NumOfTries ; ++i) //This worked fine untill I added the if + for statement below
  7.     {
  8.       delay(random(2000,4000));
  9.       time1 = millis();//take time
  10.       digitalWrite(LED1,HIGH);//make the LED switch on
  11.       if (buttonState == LOW){//When button is pressed
  12.         digitalWrite(LED1,LOW);//turn LED off
  13.         time2 = millis();//Take the time
  14.         for (int p = 0 ; p <= NumOfTries ; ++p){
  15.         time2 - time1 == myResult[p];//Find the difference in the time and put it in an array
  16.         Serial.println(myResult[p]);//Print the array with results
  17.         }
  18.      
  19.       }
  20.     }
  21.      
  22.  
  23.  
  24.  
  25.  
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement