detonation sound and timer sound

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
jacksonbell20
Date:
Mon Jan 23 19:19:04 2017 +0000
Commit message:
functioning detonation and timer sounds

Changed in this revision

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
diff -r 000000000000 -r b61d0b826228 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Jan 23 19:19:04 2017 +0000
@@ -0,0 +1,48 @@
+#include "mbed.h"
+
+PwmOut speaker(p21);
+float frequency = 800;
+float wait_time = 1.000; 
+InterruptIn boom(p5);
+void detonation();
+    
+int main() 
+{    
+    boom.rise(&detonation);
+    while(1)
+    {
+        speaker.period(1.0/(2.0*frequency));
+        speaker = 0.5;
+        wait(0.15);
+        speaker = 0;
+        wait(0.35);
+        speaker.period(1.0/(2.0*(frequency + 100)));
+        speaker = 0.5;
+        wait(0.15);
+        speaker = 0;
+        wait(wait_time);
+        frequency++;
+        wait_time = wait_time - 0.002;
+    }    
+}
+
+void detonation()
+{
+    for(int i = 0; i < 20; i++)
+    {
+        speaker.period(1.0/(2.0*frequency + 100));
+        speaker = 0.5;
+        wait(0.05);
+        speaker = 0;
+        wait(0.02);
+        speaker.period(1.0/(2.0*(frequency + 100)));
+        speaker = 0.5;
+        wait(0.05);
+        speaker = 0;
+        wait(0.02);
+    }
+        speaker.period(1.0/(2.0*200));
+        speaker = 0.4;
+        wait(2);
+    
+}
\ No newline at end of file
diff -r 000000000000 -r b61d0b826228 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Jan 23 19:19:04 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ad3be0349dc5
\ No newline at end of file