Advertisement
Guest User

Untitled

a guest
Jan 26th, 2014
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.05 KB | None | 0 0
  1. #define TARGET 32
  2. #define TIMELIMIT_MILLIS 1000
  3.  
  4. int leds[5] = {13, 12, 11, 10, 9};
  5. int buttons[5] = {8, 7, 6, 5, 4};
  6. int niveau = 0;
  7. int ledList[TARGET];
  8.  
  9. void setup() {
  10.     for(int i = 0; i<5;i++){
  11.         pinMode(leds[i], OUTPUT);
  12.         pinMode(buttons[i],INPUT); //Initializing button as input
  13.         digitalWrite(buttons[i],HIGH); //Enabling the internal Arduino pullup-resistor
  14.     }
  15. }
  16. void ledSequence()
  17. {
  18.     for(int i=0; i<=niveau; i++)
  19.     {
  20.         digitalWrite(ledList[i + 8],HIGH);
  21.         delay(1000);
  22.         digitalWrite(ledList[i + 8],LOW);
  23.         delay(1000);
  24.     }
  25. }
  26. void loop()
  27. {
  28.     ledList[niveau] = random(1 , 5);
  29.     ledSequence();
  30.     delay(2000);
  31.     niveau++;
  32.     /*
  33.     IF niveau EQUALS TARGET
  34.     //Game is won, display it somehow
  35.     ELSE
  36.     WRONGCOUNT = 0
  37.     FOR CURRENT_POSITION = 0; CURRENT_POSITION < niveau; CURRENT_POSITION++
  38.         TIMESTAMP = CURRENT_TIME_MILLIS()
  39.         BOOLEAN CORRECTED = FALSE
  40.         WHILE TIMESTAMP < TIMELIMIT_MILLIS
  41.             IF(READ(ledList[CURRENT_POSITION]-1))
  42.                 CORRECTED = TRUE
  43.     IF WRONGCOUNT > 0
  44.     //You failed!
  45.     ELSE
  46.     //You did it! Time to loop again
  47.     */
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement