Piano Tiles game
.
Overview
This mbed mini-project creates a game called “Piano Tiles”, where the user has to tap on the black tiles while avoiding the white tiles. Each correct tap results in a musical tone played, and taps in quick succession plays the famous song Fur Elise. The capacitive touchpad serves as the touchpad for input signals to the mbed. The score is measured on how fast it takes the player to achieve a score of 100 correct taps. An online demo is available to be played here: https://scratch.mit.edu/projects/21596393/
Hookup Guide
The mbed to different device hookups are shown below:
uLCD-144-G2
mbed | uLCD Header |
---|---|
VU = 5V | uLCD Header |
Gnd | Gnd |
P28 | RX |
P27 | TX |
P30 | Reset |
MPR121 I2C Capacitive Touch Sensor
mbed | Touch Keypad | Pullups |
---|---|---|
Gnd | Gnd | |
P9 | SDA | 4.7K |
P10 | SCL | 4.7K |
P26 | IRQ | |
Vout (3.3 V) | Vcc |
SDFileSystem
mbed | SDFileSystem |
---|---|
P8 | CS |
P5 | DI |
Vout | Vcc |
P7 | SCK |
Gnd | Gnd |
P6 | DO |
CD |
Speaker
mbed | TPA2005D1 | Speaker | Potentiometer |
---|---|---|---|
Gnd | Pwr - | ||
Vout (3.3 V) | Pwr + | ||
P21, P18 | In+ | ||
Out + | + | ||
Out - | - | ||
Vol | plug |
Note
An external power supply might be needed to hook up to the TPA2005D1 and speaker chip since the mbed might not be able to supply power to all the components. If it is needed, hook up 5V to Pwr+ on the TPA2005DA chip and Gnd to a common ground.
Program
The objective of the game is to achieve a score of 100 as fast as possible without tapping a white tile. It starts off initializing tiles for the first four notes being played. The game starts as soon as you press on the first tile. The tiles update themselves after every black tile is hit. The placement of the black tiles are based on the tone of the note that is being played. If a white tile is hit, the game stops and you get a game over screen if your score is less than 100. A song will play when the game ends.
MPR121 touchpad | Tile on LCD screen |
---|---|
0 | Left Tile |
4 | Middle Tile |
8 | Right Tile |
Video
Code/Library
Import programPianoTiles
an mbed tile music game using a capacitive touchpad and uLCD
Further Implementations
- Add more songs to the start menu so the user can choose which song they would like to play.
- Add a moving piano tiles option to the menu.
- Complex and more detailed graphics
- Better music synchronization by determining the length of all the notes
Please log in to post comments.