suman shavi / Mbed 2 deprecated motionsensor

Dependencies:   mbed

Fork of HelloWorld by Simon Ford

Files at this revision

API Documentation at this revision

Comitter:
sumanshavi
Date:
Thu Dec 01 10:39:34 2016 +0000
Parent:
1:03c191369089
Child:
3:085dbf0f0726
Commit message:
motionsensor

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
motionsensor.h Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sun Jan 01 20:57:57 2012 +0000
+++ b/main.cpp	Thu Dec 01 10:39:34 2016 +0000
@@ -1,12 +1,20 @@
+
 #include "mbed.h"
+ 
+DigitalOut buzzer(p19);
 
-DigitalOut myled(LED1);
-
-int main() {
+DigitalIn motion(p29);  
+ int main() {  
+ 
+    wait(2); //Wait for sensor to take snap shot of still room
+    
     while(1) {
-        myled = 1;
-        wait(0.2);
-        myled = 0;
-        wait(0.2);
+        if (motion==0){
+            buzzer=1;
+            wait(2);
+        }
+        else
+            buzzer=0;
+            
     }
-}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/motionsensor.h	Thu Dec 01 10:39:34 2016 +0000
@@ -0,0 +1,19 @@
+#include "mbed.h"
+ 
+DigitalOut buzzer(p19);
+
+DigitalIn motion(p29);  
+ int main() {  
+ 
+    wait(2); //Wait for sensor to take snap shot of still room
+    
+    while(1) {
+        if (motion==0){
+            buzzer=1;
+            wait(2);
+        }
+        else
+            buzzer=0;
+            
+    }
+}
\ No newline at end of file