Example using the user button on DISCO L475E IOT01, using interrupts

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
lmottola
Date:
Thu Nov 08 17:09:25 2018 +0000
Commit message:
Initial commit

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 fc82b2d5fe07 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 08 17:09:25 2018 +0000
@@ -0,0 +1,17 @@
+#include "mbed.h"
+
+InterruptIn button(USER_BUTTON);
+DigitalOut led(LED1);
+DigitalOut heartbeat(LED2);
+
+void toggle() {
+    led = !led;
+}
+
+int main() {
+    button.rise(&toggle);  // Call toggle function on the rising edge
+    while(1) {             // Wait around, interrupts will interrupt this!
+        heartbeat = !heartbeat;
+        wait(0.25);
+    }
+}
diff -r 000000000000 -r fc82b2d5fe07 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 08 17:09:25 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file