![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
USes Sdcard reader, uLCD display, Speaker, Keypad, and Potenitometer slider to control volume
Dependencies: 4DGL-uLCD-SE FatFileSystem SDFileSystem mbed wave_player
Fork of MPR121_Demo by
Revision 1:4d4dcc154052, committed 2015-03-11
- Comitter:
- ryanmc
- Date:
- Wed Mar 11 20:13:09 2015 +0000
- Parent:
- 0:e09703934ff4
- Commit message:
- lksdf
Changed in this revision
diff -r e09703934ff4 -r 4d4dcc154052 4DGL-uLCD-SE.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/4DGL-uLCD-SE.lib Wed Mar 11 20:13:09 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/4180_1/code/4DGL-uLCD-SE/#e39a44de229a
diff -r e09703934ff4 -r 4d4dcc154052 FatFileSystem.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FatFileSystem.lib Wed Mar 11 20:13:09 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/AdamGreen/code/FatFileSystem/#6ceefe1c53e4
diff -r e09703934ff4 -r 4d4dcc154052 SDFileSystem.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Wed Mar 11 20:13:09 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/SomeRandomBloke/code/SDFileSystem/#9c5f0c655284
diff -r e09703934ff4 -r 4d4dcc154052 main.cpp --- a/main.cpp Wed Mar 16 01:49:13 2011 +0000 +++ b/main.cpp Wed Mar 11 20:13:09 2015 +0000 @@ -1,39 +1,43 @@ -/* -Copyright (c) 2011 Anthony Buckton (abuckton [at] blackink [dot} net {dot} au) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - #include <mbed.h> #include <string> #include <list> - #include <mpr121.h> +#include "mbed.h" +#include "SDFileSystem.h" +#include "wave_player.h" +#include "uLCD_4DGL.h" +#include <iostream> +#include <fstream> +using namespace std; + +SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board +AnalogOut DACout(p18); +wave_player waver(&DACout); +uLCD_4DGL uLCD(p28, p27, p30); // serial tx, serial rx, reset pin; +AnalogIn pot(p20); // Potentiometer slider +Ticker timerz; +InterruptIn button(p12); DigitalOut led1(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); DigitalOut led4(LED4); +float ain; +int kp; +bool lock = false; +int vol = 14; +bool playing = true; + + // Create the interrupt receiver object on pin 26 InterruptIn interrupt(p26); +void volumechange() { + ain = pot.read(); + vol = ((floor(ain*100)) ); + } + // Setup the Serial to the PC for debugging Serial pc(USBTX, USBRX); @@ -44,10 +48,23 @@ // constructor(i2c object, i2c address of the mpr121) Mpr121 mpr121(&i2c, Mpr121::ADD_VSS); + + +void call_speaker_code(int key_code) { + if (key_code != 0) { + pc.printf("key code: %d\r\n", key_code); + ///////////////////////////////////// + // Speaker/SD card code goes here... + // ex. Play song 1 + + } +} void fallInterrupt() { int key_code=0; int i=0; int value=mpr121.read(0x00); + + if (lock == false) { value +=mpr121.read(0x01)<<8; // LED demo mod by J. Hamblen //pc.printf("MPR value: %x \r\n", value); @@ -60,9 +77,12 @@ led3=(key_code>>1) & 0x01; led2=(key_code>>2) & 0x01; led1=(key_code>>3) & 0x01; + call_speaker_code(key_code); + kp = key_code; + } } int main() { - + pc.printf("\nHello from the mbed & mpr121\n\r"); unsigned char dataArray[2]; @@ -114,12 +134,206 @@ interrupt.fall(&fallInterrupt); interrupt.mode(PullUp); - + + timerz.attach(&volumechange, .25); + //////////////////////////////////// while (1) { - wait(5); - pc.printf("."); - } -} + + + if(kp == 1){ + lock = true; + uLCD.cls(); + uLCD.locate(0,0); + uLCD.printf("Movie Title: \nChristmas Vacation \n"); + // Play MUSIC CHOICE + FILE *wave_file; + //printf("\n\n\nHello, wave world!\n"); + wave_file=fopen("/sd/cv.wav", "r"); + waver.play(wave_file); + fclose(wave_file); + + + wait(1); + kp = 0; + lock = false; + } + + else if(kp == 2){ + lock = true; + uLCD.cls(); + uLCD.locate(0,0); + uLCD.printf("Music Artist: \n Psy \n\n Song Title: \n Gangnam Style \n"); + // Play MUSIC CHOICE + FILE *wave_file; + //printf("\n\n\nHello, wave world!\n"); + wave_file=fopen("/sd/psy.wav", "r"); + waver.play(wave_file); + fclose(wave_file); + wait(1); + kp = 0; + lock = false; + } + + else if(kp == 3){ + lock = true; + uLCD.cls(); + uLCD.locate(0,0); + uLCD.printf("Music Artist: \n Led Zeppelin \n \n Song Title: \n Kashmir\n"); + // Play MUSIC CHOICE + FILE *wave_file; + //printf("\n\n\nHello, wave world!\n"); + wave_file=fopen("/sd/led.wav", "r"); + waver.play(wave_file); + fclose(wave_file); + wait(1); + kp = 0; + lock = false; + } + + else if(kp == 4){ + lock = true; + uLCD.cls(); + uLCD.locate(0,0); + uLCD.printf("Movie Title: \n Forrest Gump \n"); + // Play MUSIC CHOICE + FILE *wave_file; + //printf("\n\n\nHello, wave world!\n"); + wave_file=fopen("/sd/boc.wav", "r"); + waver.play(wave_file); + fclose(wave_file); + wait(1); + kp = 0; + lock = false; + } + + else if(kp == 5){ + lock = true; + uLCD.cls(); + uLCD.locate(0,0); + uLCD.printf("Movie Title: \n Forrest Gump \n \n"); + // Play MUSIC CHOICE + FILE *wave_file; + //printf("\n\n\nHello, wave world!\n"); + wave_file=fopen("/sd/shrimp.wav", "r"); + waver.play(wave_file); + fclose(wave_file); + wait(1); + kp = 0; + lock = false; + } + + else if(kp == 6){ + lock = true; + uLCD.cls(); + uLCD.locate(0,0); + uLCD.printf("Movie Title: \n TombStone \n \n I'm Your Huckleberry..."); + // Play MUSIC CHOICE + FILE *wave_file; + //printf("\n\n\nHello, wave world!\n"); + wave_file=fopen("/sd/doc.wav", "r"); + waver.play(wave_file); + fclose(wave_file); + wait(1); + kp = 0; + lock = false; + } + + else if(kp == 7){ + lock = true; + uLCD.cls(); + uLCD.locate(0,0); + uLCD.printf("Movie Title: \n Rush Hour \n"); + // Play MUSIC CHOICE + FILE *wave_file; + //printf("\n\n\nHello, wave world!\n"); + wave_file=fopen("/sd/rushhour.wav", "r"); + waver.play(wave_file); + fclose(wave_file); + wait(1); + kp = 0; + lock = false; + } + + else if(kp == 8){ + lock = true; + uLCD.cls(); + uLCD.locate(0,0); + uLCD.printf("Movie Title: \n Meet the Parents \n"); + // Play MUSIC CHOICE + FILE *wave_file; + //printf("\n\n\nHello, wave world!\n"); + wave_file=fopen("/sd/meet.wav", "r"); + waver.play(wave_file); + fclose(wave_file); + wait(1); + kp = 0; + lock = false; + } + + else if(kp == 9){ + lock = true; + uLCD.cls(); + uLCD.locate(0,0); + uLCD.printf("Music Artist: \n Glen Miller \n \n Song Title: In the Mood \n"); + // Play MUSIC CHOICE + FILE *wave_file; + //printf("\n\n\nHello, wave world!\n"); + wave_file=fopen("/sd/glenmiller.wav", "r"); + waver.play(wave_file); + fclose(wave_file); + wait(1); + kp = 0; + lock = false; + } + + else if(kp == 10){ + lock = true; + uLCD.cls(); + uLCD.locate(0,0); + uLCD.printf("Music Artist: \n El dudio \n \n Song Title: \n Guitarra de Noche\n"); + // Play MUSIC CHOICE + FILE *wave_file; + //printf("\n\n\nHello, wave world!\n"); + wave_file=fopen("/sd/gut.wav", "r"); + waver.play(wave_file); + fclose(wave_file); + wait(1); + kp = 0; + lock = false; + } + + else if(kp == 11){ + lock = true; + uLCD.cls(); + uLCD.locate(0,0); + uLCD.printf("Movie Title: \n The Lion King \n"); + // Play MUSIC CHOICE + FILE *wave_file; + //printf("\n\n\nHello, wave world!\n"); + wave_file=fopen("/sd/lionking.wav", "r"); + waver.play(wave_file); + fclose(wave_file); + wait(1); + kp = 0; + lock = false; + } + + else if(kp == 12){ + lock = true; + uLCD.cls(); + uLCD.locate(0,0); + uLCD.printf("Movie Title: \n Anchor Man \n"); + // Play MUSIC CHOICE + FILE *wave_file; + //printf("\n\n\nHello, wave world!\n"); + wave_file=fopen("/sd/anchor.wav", "r"); + waver.play(wave_file); + fclose(wave_file); + wait(1); + kp = 0; + lock = false; + } + + }//ends while +}//ends main - -
diff -r e09703934ff4 -r 4d4dcc154052 wave_player.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wave_player.lib Wed Mar 11 20:13:09 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/ryanmc/code/wave_player/#8d5ce55ed5de