The popcorn song on 1 wire. Just add a piezo buzzer on p23 !

Dependencies:   mbed beep

Revision:
0:a0cac22ff2e7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri May 20 15:59:17 2011 +0000
@@ -0,0 +1,123 @@
+#include "mbed.h"
+#include "beep.h"
+Beep buzzer(p23);
+
+DigitalOut myled(LED1);
+
+void play(char* note);
+
+void popcorn() {
+
+    play("e");
+    play("d");
+    play("e");
+    play("c");
+    play("gb");
+    play("c");
+    play("eb");
+    play("w");
+    play("e");
+    play("d");
+    play("e");
+    play("c");
+    play("gb");
+    play("c");
+    play("eb");
+    play("w");
+
+    play("e");
+    play("f#");
+    play("g");
+    play("f#");
+    play("g");
+    play("e");
+    play("f#");
+    play("e");
+    play("f#");
+    play("d");
+    play("e");
+    play("d");
+    play("e");
+    play("d");
+    play("e");
+
+    play("w");
+
+    play("e");
+    play("d");
+    play("e");
+    play("c");
+    play("gb");
+    play("c");
+    play("eb");
+    play("w");
+    play("e");
+    play("d");
+    play("e");
+    play("c");
+    play("gb");
+    play("c");
+    play("eb");
+    play("w");
+
+    play("e");
+    play("f#");
+    play("g");
+    play("f#");
+    play("g");
+    play("e");
+    play("f#");
+    play("e");
+    play("f#");
+    play("d");
+    play("e");
+    play("d");
+    play("e");
+    play("d");
+    play("g");
+
+}
+
+
+void play(char* note) {
+    if (note=="a") {
+        buzzer.beep(880,0.1);
+    }
+    if (note=="b") {
+        buzzer.beep(987,0.1);
+    }
+    if (note=="c") {
+        buzzer.beep(1024,0.1);
+    }
+    if (note=="d") {
+        buzzer.beep(1175,0.1);
+    }
+    if (note=="e") {
+        buzzer.beep(1319,0.1);
+    }
+    if (note=="f") {
+        buzzer.beep(1397,0.1);
+    }
+    if (note=="g") {
+        buzzer.beep(1568,0.1);
+    }
+
+    if (note=="gb") {
+        buzzer.beep(830,0.1);
+    }
+    if (note=="eb") {
+        buzzer.beep(659,0.1);
+    }
+    if (note=="f#") {
+        buzzer.beep(1480,0.1);
+    }
+    if (note=="w") {
+        wait(0.05);
+    }
+    wait (0.2); //wait while the note plays.
+}
+
+
+int main() {
+    popcorn();
+}