"SongPop Game"
Overview
The project aims to use a few I/O devices to recreate the popular smart phone game, "SongPop." Following power up and initialization, the code will check to see if an SD card is docked, and then proceed to set up four push button interrupts. These serve as the inputs for the game. A song is automatically played until the user inputs an answer choice. After the choice is entered, the code compares the the choice with the song actually playing. If it is correct, the speaker will beep, and the fourth on board LED will flash. If incorrect, song will still change, but there will be no indication given by the fourth LED.
Necessary Parts
- 4GDLuLCD
- Four Push buttons
- SD Card
- SD Card Breakout Board
- Speaker
- Speaker Driver Circuit
Pin Outs
uLCD
mbed | uLCD Header | uLCD Cable |
---|---|---|
Vu | 5V | 5V |
GND | GND | GND |
TX(p28) | RX | TX |
RX(27) | TX | RX |
p30 | Reset | Reset |
SD Card Breakout
This link contains the necessary libraries and code examples to properly use the SD File System. However, there is a difference between this library and the one we used. This standard library does not utilize the chip detect function, therefore; the p14 connection shown below is not necessary for implementation.
mbed | SD Card Reader |
---|---|
p8 | CS |
p5 | DI |
Vout (3.3V) | VCC |
p7 | SCK |
GND | GND |
p6 | DO |
p14 | CD |
Pushbuttons
The push buttons in this code were used as four interrupts to check the value of the song being played against the user's input. Each selection whether right or wrong will recall the random function and give a new song selection for all four choices.
mbed | choice |
---|---|
p9 | A |
p10 | B |
p11 | C |
p12 | D |
Speaker
Use the link below to access the speaker driver circuit, and many code examples for speaker use on the mbed. For our purpose the input to the speaker amplifier circuit is pin 18. The amplifier circuit is shown below. This amplifier is necessary to get the speaker volume to sufficient levels.
Code
Import programSongPop
Final Working Version of Songpop
Image/Video
Below is the assembled product. All items outline above are highlighted by arrows. All other items on the board are not used in this project. Shown below is the video of the project working. Notice, when the correct answer is selected, it stops the song, LED4 flashes, and the speaker beeps. When incorrect, it stops and changes the song.
Issues/Bugs
The random function in c/c++ is notoriously predictable for a small sample size. We spent a lot of time attempting to generate our own random function, but were ultimately unsuccessful. Thus, due to the uneven distribution of rand(), there are several cases where one particular answer choice is much more common.
Given more time, this would be the largest area of focus, as it is integral to having an unpredictable, fun game.
Please log in to post comments.