Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed wave_player mbed-rtos 4DGL-uLCD-SE RTOS FATFileSystem
main.cpp
- Committer:
- 4180_1
- Date:
- 2013-11-01
- Revision:
- 9:f1aebfbe7e78
- Parent:
- 4:f8a5c8aa895a
- Child:
- 10:21943bd35341
File content as of revision 9:f1aebfbe7e78:
#include "mbed.h"
#include "USBHostMSD.h"
#include "wave_player.h"
//mbed Application board waveplayer demo
//Plays the wave file "sample.wav" on the USB flash drive
//Outputs to onboard speaker (but at very low volume)
//and the Audio Out jack for connection to a set of amplified PC speakers (at higher volume)
//Needs a USB flash drive inserted with the wav file on it to run
//Analog Out Jack
AnalogOut DACout(p18);
//On Board Speaker
PwmOut PWMout(p26);
wave_player waver(&DACout,&PWMout);
int main()
{
USBHostMSD msd("usb");
FILE *wave_file;
//setup PWM hardware for a Class D style audio output
PWMout.period(1.0/400000.0);
printf("\n\n\nHello, wave world!\n");
// wait until connected to a USB device
while(!msd.connect()) {
Thread::wait(500);
}
//open wav file and play it
wave_file=fopen("/usb/sample.wav","r");
waver.play(wave_file);
fclose(wave_file);
//end of program
while(1) {};
}