
Reproducir audio
Dependencies: mbed wave_player SDFileSystem TextLCD
Diff: main.cpp
- Revision:
- 2:277001f3ae5c
- Parent:
- 0:bdbd3d6fc5d5
--- a/main.cpp Tue May 16 05:18:55 2017 +0000 +++ b/main.cpp Mon Jul 08 14:54:14 2019 +0000 @@ -1,19 +1,51 @@ #include "mbed.h" +#include "TextLCD.h" #include "SDFileSystem.h" - -SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board - -int main() { - printf("Hello World!\n"); - - mkdir("/sd/mydir", 0777); +#include "wave_player.h" + + + +AnalogOut DACout(PTE30); +wave_player waver(&DACout); +SDFileSystem sd(PTD2, PTD3, PTD1, PTD0, "sd"); // Pines del modulo sd + + +Serial pc (USBTX,USBRX);// Comunicacion serial con el pc +float p,q,w; +int sel; + + +void receivedByte()// Interrupcion pc +{ + int byteReceived = pc.getc();//Variable que viene del pc + + switch (byteReceived) { + + case 'x' :// Segunda etapa: Primera terapia calma -.- + sel=1; + + break; + + + } +} + +int main() +{ + + pc.baud(9600); + pc.attach(&receivedByte); + + - FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); - if(fp == NULL) { - error("Could not open file for write\n"); + FILE *wave_file; + while(1) { + if (sel == 1) { + + wave_file = fopen("/sd/AUDIO.wav", "r"); + waver.play(wave_file); + fclose(wave_file); + } + } - fprintf(fp, "Hello fun SD Card World!"); - fclose(fp); - - printf("Goodbye World!\n"); }