motion sensor is used to detect the any object

Dependencies:   mbed

Fork of HelloWorld by Simon Ford

Revision:
2:e78cebb5a0d5
Parent:
0:fb6bbc10ffa0
Child:
3:085dbf0f0726
--- 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