"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

http://developer.mbed.org/media/uploads/4180_1/x8185.png.pagespeed.ic.XZ5IOV2PW-.png

mbeduLCD HeaderuLCD Cable
Vu5V5V
GNDGNDGND
TX(p28)RXTX
RX(27)TXRX
p30ResetReset

SD Card Breakout

http://developer.mbed.org/media/uploads/simon/xusd-breakout_i_ma.jpg.pagespeed.ic.ipnOw2rc3y.webp

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.

SD File System Cookbook Page

mbedSD Card Reader
p8CS
p5DI
Vout (3.3V)VCC
p7SCK
GNDGND
p6DO
p14CD

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.

mbedchoice
p9A
p10B
p11C
p12D

Speaker

http://developer.mbed.org/media/uploads/4180_1/xspeaker.jpg.pagespeed.ic.ukDru5k4Rz.webp

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.

http://developer.mbed.org/media/uploads/4180_1/900xNxlm386speakercircuit.png.pagespeed.ic.bB1BshF8RT.png

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. /media/uploads/bkf34/mbed.png 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.