Example using a PIR sensor

Dependencies:   EthernetInterface mbed-rtos mbed

Fork of Seeed_Grove_PIR_Motion_Sensor_Example by Seeed

Files at this revision

API Documentation at this revision

Comitter:
terrence
Date:
Wed Mar 04 15:35:17 2015 +0000
Parent:
0:cc930b964211
Commit message:
Can't get Ethernet libs to compile.

Changed in this revision

EthernetInterface.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-rtos.lib 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/EthernetInterface.lib	Wed Mar 04 15:35:17 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/mbed_official/code/EthernetInterface/#65b0d840274c
--- a/main.cpp	Fri Aug 15 23:18:16 2014 +0000
+++ b/main.cpp	Wed Mar 04 15:35:17 2015 +0000
@@ -1,25 +1,38 @@
-
 #include "mbed.h"
 
 InterruptIn motion(D2);
+DigitalOut gLed(LED2);
+Serial pc(USBTX, USBRX);
 
 int motion_detected = 0;
+float blinkTime = .2;
 
 void irq_handler(void)
 {
     motion_detected = 1;
 }
-    
+
+void BlinkGreen(){
+            gLed = 0;  // turn myled on
+            pc.printf("LED Green \r\n");
+            wait(blinkTime);
+            gLed = 1;  // turn myled off
+            wait(blinkTime);
+}
 int main(void)
 {
+    pc.baud(115200);
     int cnt = 0;
+    gLed = 1;
     motion.rise(&irq_handler);
-    
+
     while(1) {
         if(motion_detected) {
+            BlinkGreen();
             cnt++;
             motion_detected = 0;
-            printf("Hello! I've detected %d times since reset\n", cnt);
+            pc.printf("Hello! I've detected %d times since reset\r\n", cnt);
         }
     }
 }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Wed Mar 04 15:35:17 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/mbed_official/code/mbed-rtos/#63988a2238f7
--- a/mbed.bld	Fri Aug 15 23:18:16 2014 +0000
+++ b/mbed.bld	Wed Mar 04 15:35:17 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1
\ No newline at end of file