Expo2017_example

Dependencies:   mbed

Revision:
0:493a823a2708
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun May 14 20:14:10 2017 +0000
@@ -0,0 +1,30 @@
+#include "mbed.h"
+ 
+DigitalOut led1(LED2);
+DigitalIn alarm(PTB0, PullNone); //internal pull up 
+PwmOut buzzer(PTE31);
+
+
+float freq[] = {659,554,659,554,440,494,554,587,494,659,554,400};
+float beat[] = {1,1,1,1,1,0.5,0.5,1,1,1,1,2};
+
+int main() {  
+    wait(2); //Wait for sensor to take snap shot of still room
+    
+    while(1) {
+        if (alarm){
+            led1=0;
+            for(int i = 0 ; i <= 4; i++){
+            buzzer.period(1/(2*freq[i]));
+            buzzer = 0.5;
+            wait(0.4*beat[i]);
+            } 
+        }
+        else {
+            led1=1;
+            buzzer = 0;
+             }
+             wait(1);
+    }
+
+}
\ No newline at end of file