Movie and Music Trivia Game (with volume control)
ECE 4180 LAB 4
Project Description:
We chose option two for Lab 4, which was to create a mini mbed project. So my partner and I created a Music/Movie Trivia Game. It works by pressing the key pad for a song or movie sound bite to be played out the speaker. The title of the movie or song title/Artist is displayed on the Color LCD screen so that you can verify answer you guessed from listening to the sound bite. Also incorporated into this project is a volume control slider. The slider handle can be moved to change the volume on songs.
Code
Import programMOVIE_MUSIC_TRIVIA_GAME
USes Sdcard reader, uLCD display, Speaker, Keypad, and Potenitometer slider to control volume
Gallery
Hardware
Keypad
Keypad Pin | Mbed Pin |
---|---|
GND | GND |
SDA | p9 |
SCL | p10 |
VCC | Vout |
Don't forget to use pullup resistors on I2C More info on how to use sparkfun keypads can be found here: https://developer.mbed.org/components/MPR121-I2C-Capacitive-Touch-Keypad/
Sliding Potentiometer
Slider Pin | Mbed Pin |
---|---|
GND | GND |
VCC | Vout |
Analog | p20 |
Any Analog sensor could be used, the specifics on the one used in this project can be found here: http://www.phidgets.com/docs/1112_User_Guide
SdCard
SD | Mbed Pin |
---|---|
DO | p6 |
GND | GND |
SCK | p7 |
VCC | VOUT |
DI | p5 |
CS | p8 |
More can be found on how SD Card System works here: http://developer.mbed.org/cookbook/SD-Card-File-System
uLCD
uLCD | Mbed Pin |
---|---|
5v | Vu |
RX | p27 |
TX | p28 |
GND | VOUT |
RES | p30 |
More can be found on how uLCD works here: http://developer.mbed.org/users/4180_1/notebook/ulcd-144-g2-128-by-128-color-lcd/
How the Code Works
The song/movie sound bites are stored as .wav files on the sdCard and played out the speaker.
The volume control works using the timed TICKER interrupt set to happen every 0.25 seconds.
AnalogIn pot(p20); // Potentiometer slider Ticker timerz;
void volumechange() { ain = pot.read(); vol = ((floor(ain*100)) ); }
int main() { ... ... ... timerz.attach(&volumechange, .25); while (1) { ... ... ... }
Please log in to post comments.