#define TARGET 32
#define TIMELIMIT_MILLIS 1000
int leds[5] = {13, 12, 11, 10, 9};
int buttons[5] = {8, 7, 6, 5, 4};
int niveau = 0;
int ledList[TARGET];
void setup() {
for(int i = 0; i<5;i++){
pinMode(leds[i], OUTPUT);
pinMode(buttons[i],INPUT); //Initializing button as input
digitalWrite(buttons[i],HIGH); //Enabling the internal Arduino pullup-resistor
}
}
void ledSequence()
{
for(int i=0; i<=niveau; i++)
{
digitalWrite(ledList[i + 8],HIGH);
delay(1000);
digitalWrite(ledList[i + 8],LOW);
delay(1000);
}
}
void loop()
{
ledList[niveau] = random(1 , 5);
ledSequence();
delay(2000);
niveau++;
/*
IF niveau EQUALS TARGET
//Game is won, display it somehow
ELSE
WRONGCOUNT = 0
FOR CURRENT_POSITION = 0; CURRENT_POSITION < niveau; CURRENT_POSITION++
TIMESTAMP = CURRENT_TIME_MILLIS()
BOOLEAN CORRECTED = FALSE
WHILE TIMESTAMP < TIMELIMIT_MILLIS
IF(READ(ledList[CURRENT_POSITION]-1))
CORRECTED = TRUE
IF WRONGCOUNT > 0
//You failed!
ELSE
//You did it! Time to loop again
*/
}