ver 1.0

Dependencies:   FATFileSystem SDFileSystem mbed-rtos mbed wave_player

Fork of LED_effects_w_sound by jim hamblen

LED PWM lighting effects with sounds played from *.wav files using threads and the mbed RTOS. For more info see http://developer.mbed.org/users/4180_1/notebook/led-lighting-effects-for-modelers/.

Revision:
11:50e44c84411c
Parent:
10:21943bd35341
--- a/main.cpp	Fri Dec 05 18:16:56 2014 +0000
+++ b/main.cpp	Tue Feb 20 17:54:41 2018 +0000
@@ -1,6 +1,11 @@
 #include "mbed.h"
-#include "USBHostMSD.h"
+#include "rtos.h"
+#include "SDFileSystem.h"
 #include "wave_player.h"
+
+
+SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
+
 //LED lighting effects with sound using the RTOS
 //Plays the wave file "sample.wav" on the USB flash drive
 //using waveplayer code library
@@ -142,26 +147,20 @@
     }
 }
 
-//wave player plays a *.wav file to D/A and a PWM
-wave_player waver(&DACout,&PWMout);
+//wave player plays a *.wav file to D/A
+wave_player waver(&DACout);
 
 int main()
 {
-    USBHostMSD msd("usb");
+
     FILE *wave_file;
-    //setup PWM hardware for a Class D style audio output
-    PWMout.period(1.0/400000.0);
-    // wait until connected to a USB device
-    while(!msd.connect()) {
-        Thread::wait(750);
-    }
     while(1) {
         {
             //Lighthouse demo with foghorn
             Thread thread(lighthouse); //Start LED effect thread
             for(int i=0; i<4; ++i) {
                 //open wav file and play it
-                wave_file=fopen("/usb/foghorn.wav","r");
+                wave_file=fopen("/sd/foghorn.wav","r");
                 waver.play(wave_file); //Plays (*.wav file
                 fclose(wave_file);
                 Thread::wait(1925);
@@ -174,7 +173,7 @@
             //Arc Welding with sound
             Thread thread(welding);
             //open wav file and play it
-            wave_file=fopen("/usb/welding.wav","r");
+            wave_file=fopen("/sd/welding.wav","r");
             waver.play(wave_file);
             fclose(wave_file);
             //end of welding demo;
@@ -185,7 +184,7 @@
             //code block forces thread out of scope
             Thread thread(police);
             //open wav file and play it
-            wave_file=fopen("/usb/emgsiren.wav","r");
+            wave_file=fopen("/sd/emgsiren.wav","r");
             waver.play(wave_file);
             fclose(wave_file);
             //end of police light demo;
@@ -195,7 +194,7 @@
             //Fire with sound
             Thread thread(fire);
             //open wav file and play it
-            wave_file=fopen("/usb/fire.wav","r");
+            wave_file=fopen("/sd/fire.wav","r");
             waver.play(wave_file);
             fclose(wave_file);
             //end of fire demo;
@@ -206,7 +205,7 @@
             //RR Crossing Lights with Signal Bells
             Thread thread(rrcrossing);
             //open wav file and play it
-            wave_file=fopen("/usb/SignalBell.wav","r");
+            wave_file=fopen("/sd/SignalBell.wav","r");
             waver.play(wave_file);
             fclose(wave_file);
             //end of railroad crossing demo;