mbed2
Dependencies: SDFileSystem mbed wave_player
Fork of DanceDanceRevolutionMbed2 by
Revision 1:cf186b6e4999, committed 2017-04-30
- Comitter:
- ckabuloglu
- Date:
- Sun Apr 30 00:56:39 2017 +0000
- Parent:
- 0:4669e409389d
- Commit message:
- mbed2
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 4669e409389d -r cf186b6e4999 main.cpp --- a/main.cpp Fri Apr 29 02:07:01 2016 +0000 +++ b/main.cpp Sun Apr 30 00:56:39 2017 +0000 @@ -11,22 +11,28 @@ AnalogOut DACout(p18); //music played using analog out wave_player waver(&DACout); SDFileSystem sd(p5, p6, p7, p8, "sd"); // mosi, miso, sck, cs -DigitalIn songSelected(p21); //signal from main mbed (asserted when a song has been selected) -DigitalIn specificSong(p22); //signal from main mbed (asserted which specific song should be played) +DigitalIn gameStarted(p22); //signal from main mbed (asserted when a song has been selected) + +Serial pc(USBTX, USBRX); +AnalogIn drum1(p15); + +DigitalOut led1(LED1); +DigitalOut led2(LED2); + +float reading; + void playSound(char * wav); int main(){ - while(!songSelected){ + wait(5.5); + while(!gameStarted){ + led1 = 1; //wait until the main mbed send the ready signal for playing a song (players are still readying up and selecting music) } - if(specificSong){ //a song has been selected and a '0' means Animals, and '1' means Novocaine - wait(5); //a delay so that the arrow lines up with the first note of the song - playSound("/sd/wavfiles/Novocaine2.wav"); - } - else { - wait(3.85); //a delay so that the arrow lines up with the first note of the song - playSound("/sd/wavfiles/Animals2.wav"); - } + led1 = 0; + led2 = 1; + wait(9.00); //a delay so that the arrow lines up with the first note of the song + playSound("/sd/rock.wav"); } void playSound(char * wav) @@ -35,7 +41,7 @@ // open wav file FILE *wave_file; wave_file=fopen(wav,"r"); - + // play wav file waver.play(wave_file);