Speaker Code

Dependencies:   SDFileSystem mbed wave_player

Revision:
2:f04e2e446c74
Parent:
0:bdbd3d6fc5d5
Child:
3:8ebd761c0483
--- a/main.cpp	Tue May 16 05:18:55 2017 +0000
+++ b/main.cpp	Sun Dec 04 23:53:51 2022 +0000
@@ -1,19 +1,15 @@
 #include "mbed.h"
 #include "SDFileSystem.h"
- 
+#include "wave_player.h"
 SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
- 
+AnalogOut speaker(p26); 
+wave_player waver(&speaker);
 int main() {
-    printf("Hello World!\n");   
- 
-    mkdir("/sd/mydir", 0777);
-    
-    FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
-    if(fp == NULL) {
-        error("Could not open file for write\n");
-    }
-    fprintf(fp, "Hello fun SD Card World!");
-    fclose(fp); 
- 
-    printf("Goodbye World!\n");
+    FILE *wave_file;
+    //open wav file and play it
+    wave_file=fopen("/sd/thread_sound.wav","r");
+    waver.play(wave_file);
+    fclose(wave_file);
+    //end of program
+    wait(.2);
 }