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

Dependencies:   mbed beep

Files at this revision

API Documentation at this revision

Comitter:
DaveStyles
Date:
Fri May 20 15:59:17 2011 +0000
Commit message:
Popcorn v1.0

Changed in this revision

beep.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/beep.lib	Fri May 20 15:59:17 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/dreschpe/code/beep/#5a8242af60ba
--- /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();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri May 20 15:59:17 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912