mbed2

Dependencies:   SDFileSystem mbed wave_player

Fork of drumsMusic by Can Kabuloglu

Files at this revision

API Documentation at this revision

Comitter:
ckabuloglu
Date:
Mon May 01 11:06:57 2017 +0000
Parent:
1:cf186b6e4999
Commit message:
final push

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r cf186b6e4999 -r 6488698b9d59 main.cpp
--- a/main.cpp	Sun Apr 30 00:56:39 2017 +0000
+++ b/main.cpp	Mon May 01 11:06:57 2017 +0000
@@ -1,20 +1,14 @@
-/*
-File: DanceDanceFullGame_SECONDMBED.main.cpp
-Author: Akshay Nagendra, Weiyu Liu
-Description: File responsible for operating the second mbed, in charge of listening to the main mbed for a ready signal and then playing the music for the game
-*/
 #include "mbed.h"
 #include "wave_player.h"
 #include "SDFileSystem.h"
 
-//setup variables and objects for music playing
-AnalogOut DACout(p18); //music played using analog out
-wave_player waver(&DACout);
-SDFileSystem sd(p5, p6, p7, p8, "sd"); // mosi, miso, sck, cs
-DigitalIn gameStarted(p22); //signal from main mbed (asserted when a song has been selected)
+// Define pins
+SDFileSystem sd(p5, p6, p7, p8, "sd"); 
+AnalogOut DACout(p18); 
+wave_player wave(&DACout);
+DigitalIn gameStarted(p22);
 
-Serial pc(USBTX, USBRX);
-AnalogIn drum1(p15);
+// Serial pc(USBTX, USBRX);
 
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
@@ -24,26 +18,29 @@
 void playSound(char * wav);
 
 int main(){
+    // Wait for first mbed to pull down the pin
     wait(5.5);
+    
+    // Wait until the player hits the start button
     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)   
+        led1 = 1;  
     } 
+    
+    // LED2 indicates the that mbed will start playing the music
     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");
+    wait(8.00); // Delay to line u first note with the song
+    playSound("/sd/obladi.wav");
 }
 
-void playSound(char * wav)
-    //helper function to play the music 
-{
+// Function that plays the music
+void playSound(char * wav) {
     // open wav file
     FILE *wave_file;
     wave_file=fopen(wav,"r");
  
     // play wav file
-    waver.play(wave_file);
+    wave.play(wave_file);
 
     // close wav file
     fclose(wave_file);