const int max_level = 9;
int game_levels[max_level] = {};//game level list
int game_level = 1;//current game level
int led_pins[] = {13,12,11,10};//led pin list
int button_pins[] = {5,4,3,2};//button pin list
// 0 1 2 3
void setup() {
for(int i = 0; i < 4; i++){
pinMode(led_pins[i], OUTPUT); //sets up pinmodes for led and buttons
pinMode(button_pins[i], INPUT_PULLUP);
}
for(int i = 0; i < max_level; i++){
randomSeed(analogRead(A0));//use floating pin, for creating random number
game_levels[i] = random(0,4);
}//creates a random game
light_maxwell();//function call
}
void loop() {
}
void light_maxwell(){//void returns nothing, since we only light leds
for(int i = 0; i < game_level; i++){ //for loop goes from 0 to the game level (i)
digitalWrite(led_pins[game_levels[i]], HIGH);//use the game level to find the address of the led in the game level list
delay(500);//then use the address from the game level list to find the led PIN# in the led pins list
digitalWrite(led_pins[game_levels[i]], LOW);
delay(500);
}
}