Freedom Seeed PIR Sensor Example

Dependencies:   mbed

Fork of frdm_Grove_PIR_Example by Freescale

Simply Import this Program into your mbed compiler
Select Compile to generate the binary file
Open an Hyperterminal window and connect to the mbed Serial Port (COMxx) peripheral using speed 9600bps
Plug the Grove Shield v2 on the top of your FRDM-K64F
Connect on end of the 4-pin Grove cable to the Temperature and Humidity module and the other end to the port D2 of the Grove Adapter.

/media/uploads/GregC/pir1.jpg

Drag n drop the frdm_Grove_PIR_Example_K64F.bin into the mbed drive from your file explorer
Wait for download to complete
Press the Reset/SW1 button of your FRDM-K64F board to launch the program

Your hyperterminal window should now display how many time motion have been detected since last reset (see picture below)!!

/media/uploads/GregC/pir2.jpg

Files at this revision

API Documentation at this revision

Comitter:
GregC
Date:
Thu Dec 31 23:29:45 2015 +0000
Commit message:
Freedom Seeed Grove PIR Example

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 d444f103013a main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Dec 31 23:29:45 2015 +0000
@@ -0,0 +1,25 @@
+
+#include "mbed.h"
+
+InterruptIn motion(D2);
+
+int motion_detected = 0;
+
+void irq_handler(void)
+{
+    motion_detected = 1;
+}
+    
+int main(void)
+{
+    int cnt = 0;
+    motion.rise(&irq_handler);
+    
+    while(1) {
+        if(motion_detected) {
+            cnt++;
+            motion_detected = 0;
+            printf("Hello! I've detected %d times since reset\n", cnt);
+        }
+    }
+}
diff -r 000000000000 -r d444f103013a mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Dec 31 23:29:45 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013
\ No newline at end of file