Example program using interrupts with PIR motion sensor.

Dependencies:   mbed

Revision:
0:8aaf23a881c1
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