ECE 4180 Lab 2 Part 14

Dependencies:   mbed

Fork of song_demo_PWM by jim hamblen

Revision:
0:b2fdf3770282
Child:
1:2e6ea42675c7
diff -r 000000000000 -r b2fdf3770282 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Jan 20 03:02:37 2013 +0000
@@ -0,0 +1,19 @@
+#include "mbed.h"
+#include "Speaker.h"
+
+// Speaker test program - euro police style siren now using new Speaker class method
+// for documentation see http://mbed.org/users/4180_1/notebook/using-a-speaker-for-audio-output/
+// can also be used to play a song, if you have the notes and durations
+// for musical note frequencies see http://en.wikipedia.org/wiki/Piano_key_frequencies
+
+int main()
+{
+// setup instance of new Speaker class, mySpeaker using pin 21
+// the pin must be a PWM output pin
+    Speaker mySpeaker(p21);
+    // loops forever playing two notes on speaker
+    while(1) {
+        mySpeaker.PlayNote(969.0,0.5,0.5);
+        mySpeaker.PlayNote(800.0,0.5,0.5);
+    }
+}