interrupt

Dependencies:   mbed

Revision:
0:a3c8e021fd64
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jan 18 10:22:36 2017 +0000
@@ -0,0 +1,19 @@
+#include "mbed.h"
+ 
+InterruptIn button(PB_13);
+DigitalOut led(LED2);
+ 
+void flip() {
+    led = !led;
+    wait(0.1);
+}
+ 
+int main() {
+    button.mode(PullUp);
+    wait(0.01);
+    button.fall(&flip);  // attach the address of the flip function to the rising edge
+    led = 0;
+    while(1) {           // wait around, interrupts will interrupt this!
+        
+    }
+}
\ No newline at end of file