Example using a PIR sensor
Dependencies: EthernetInterface mbed-rtos mbed
Fork of Seeed_Grove_PIR_Motion_Sensor_Example by
Revision 1:9f54cd329503, committed 2015-03-04
- 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
diff -r cc930b964211 -r 9f54cd329503 EthernetInterface.lib --- /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
diff -r cc930b964211 -r 9f54cd329503 main.cpp --- 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); } } } +
diff -r cc930b964211 -r 9f54cd329503 mbed-rtos.lib --- /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
diff -r cc930b964211 -r 9f54cd329503 mbed.bld --- 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