Expanded Pitch
According to science, the average person can hold a set of about 7 digits in his/her working memory at any given time, without any memorization techniques. Think you got what it takes to defy science? In the game memory match, the player is flashed a sequence of numbers(as displayed on the number display) and he/she must input the sequence in the correct order using the respective buttons. Each button corresponds to a number.
HardwareOur hardware consists of three main components: the controller, the boards, and the modules. For our controller, we built a bread board with 4 buttons that connects to 4 pins of our board using jumper cables. Each time a button is pressed the circuit is complete and we read a voltage at the pin. Our booster board is on the bottom of our launch pad and connected to our booster board are the buzzer and the 4 digit display.
SoftwareUsing the arduino environment we created a program that runs the game. The code continuously runs a loop. Each iteration of the loop can be thought of as a round of the game. First the game will add on a number to the sequence of numbers that the user has to memorize, then the game will display the sequence of numbers using functions that display the numbers and wait for user input. Each time the user inputs the correct number the game plays a nice sound on the buzzer and then waits for the user to input the next correct number, this is done using indexes and arrays. If the user inputs the wrong number, the code runs the fail function which displays all zeros on and plays an ugly sound.
The game keeps track of the variables user_index and game_index.user_index indicates which number in the array the player is in inputting. game_index indicates the last number that was displayed to the user. Thus when user_index goes beyond game_index, the game moves on to the next round. After the numbers are displayed to the user, the game will wait until this condition is met, buttons are associated with an interrupt. In the interrupt function, the game checks if the correct button was pressed and the game either checks for the next number or fails the user.
Comments
Please log in or sign up to comment.