In this game, the Arduino will produce a random pattern of short and long LED flashes. The user must replicate these flashes by pressing the button quickly, or pressing and holding the button. The game is won if the player beats ten rounds. The game is lost if the player misses any pattern.
Button 1 = enter (used to start the game)
Button 2 = pattern (used to enter the pattern)
LED Green = (flashing once indicates the beginning of the player’s turn, flashing twice indicates a correct answer)
LED Red = (flashing twice indicates an incorrect answer)
LED Yellow = (flashes the pattern that the user must enter)
Press button one to start.
The game randomly selects a flash pattern for the yellow LED.
There are two possible flash types:
In the first round, the pattern will consist of two flashes.
With each successful answer the next pattern will get one flash longer.
The flash pattern is stored in an array (with 11 positions?)
The green LED will then flash once to indicate that it is the player’s turn.
Using button 2, the player must replicate the flash pattern (A short press matches a short flash, and a long press matches a long flash).
The yellow LED will light up when the player presses button to help him/her judge how long to hold the button.
The player’s answer is held in an array (with 11 positions?)
The game checks whether the player’s entry matches the previous flash pattern.
If it does, the green LED flashes twice to indicate a correct answer and then a new pattern is given.
If not, the red LED flashes twice to indicate an incorrect answer.
Both arrays are reset.
When the pattern length = 11 the player wins and all the LEDs flash
The player may press button 1 at any time to reset the game.
Question for Joel:
Is it possible to use arrays when the length of the pattern and answer are changing?