Example program using interrupts with PIR motion sensor.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
awood37
Date:
Fri Mar 06 22:02:17 2015 +0000
Commit message:

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 8aaf23a881c1 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Mar 06 22:02:17 2015 +0000
@@ -0,0 +1,19 @@
+#include "mbed.h"
+//example using InterruptIn with the input from the PIR motion sensors
+InterruptIn alarm(p11);
+DigitalOut led(LED1);
+DigitalOut flash(LED4);
+ 
+void flip() {
+    led = !led;
+}
+ 
+int main() {
+    alarm.mode(PullUp);
+    wait(2);
+    alarm.fall(&flip);  // attach the address of the flip function to the falling edge
+    while(1) {           // wait around, interrupts will interrupt
+        flash = !flash;
+        wait(0.25);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 8aaf23a881c1 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Mar 06 22:02:17 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7e07b6fb45cf
\ No newline at end of file