Signal Generator
Dependencies: IniManager RA8875 Watchdog mbed-rtos mbed
Fork of speaker_demo_Analog by
Diff: main.cpp
- Revision:
- 0:1c8118ee4106
- Child:
- 1:dd07e1deec6c
diff -r 000000000000 -r 1c8118ee4106 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jan 21 03:37:11 2013 +0000 @@ -0,0 +1,22 @@ +#include "mbed.h" +// Audio output demo for speaker +// Speaker Class demo - plays a note on the analog output pin +// 32 data points on one sine wave cycle are precomputed, +// scaled, stored in an array and +// continuously output to the Digital to Analog convertor + +// add Speaker class and PlayNote +// PlayNote args are frequency in hz (<=5000), duration in secs , and volume(0.0..1.0) +#include "Speaker.h" + +int main() +{ +// setup instance of new Speaker class, mySpeaker +// the pin must be the AnalogOut pin - p18 + Speaker mySpeaker(p18); + // loops forever playing two notes on speaker using analog samples + while(1) { + mySpeaker.PlayNote(969.0, 0.5, 1.0); + mySpeaker.PlayNote(800.0, 0.5, 1.0); + } +}