interrupt sample

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
rockstar
Date:
Sat Aug 22 10:33:50 2015 +0000
Commit message:
interrupt sample

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 a20448f74532 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Aug 22 10:33:50 2015 +0000
@@ -0,0 +1,18 @@
+#include "mbed.h"
+
+InterruptIn button(p5); //define and name the interrupt input
+DigitalOut led(LED1);
+DigitalOut flash(LED4);
+
+void ISR1() { //this is the response to interrupt, i.e. the ISR
+    led = !led;
+}
+
+int main() {
+    button.rise(&ISR1); // attach the address of the ISR function to the
+    // interrupt rising edge
+    while(1) { // continuous loop, ready to be interrupted
+        flash = !flash;
+        wait(1);
+    }
+}
diff -r 000000000000 -r a20448f74532 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Aug 22 10:33:50 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8ed44a420e5c
\ No newline at end of file