Speaker Code

Dependencies:   SDFileSystem mbed wave_player

Committer:
emanuel22e
Date:
Sun Dec 04 23:53:51 2022 +0000
Revision:
2:f04e2e446c74
Parent:
0:bdbd3d6fc5d5
Child:
3:8ebd761c0483
Speaker Code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:bdbd3d6fc5d5 1 #include "mbed.h"
mbed_official 0:bdbd3d6fc5d5 2 #include "SDFileSystem.h"
emanuel22e 2:f04e2e446c74 3 #include "wave_player.h"
mbed_official 0:bdbd3d6fc5d5 4 SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
emanuel22e 2:f04e2e446c74 5 AnalogOut speaker(p26);
emanuel22e 2:f04e2e446c74 6 wave_player waver(&speaker);
mbed_official 0:bdbd3d6fc5d5 7 int main() {
emanuel22e 2:f04e2e446c74 8 FILE *wave_file;
emanuel22e 2:f04e2e446c74 9 //open wav file and play it
emanuel22e 2:f04e2e446c74 10 wave_file=fopen("/sd/thread_sound.wav","r");
emanuel22e 2:f04e2e446c74 11 waver.play(wave_file);
emanuel22e 2:f04e2e446c74 12 fclose(wave_file);
emanuel22e 2:f04e2e446c74 13 //end of program
emanuel22e 2:f04e2e446c74 14 wait(.2);
mbed_official 0:bdbd3d6fc5d5 15 }