Blink using Ticker object

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
lmottola
Date:
Thu Nov 08 12:18:12 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 d9ec23dd131e main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 08 12:18:12 2018 +0000
@@ -0,0 +1,17 @@
+#include "mbed.h"
+
+Ticker toggle_led_ticker;
+
+DigitalOut led1(LED1);
+
+void toggle_led() {
+    led1 = !led1;
+}
+
+int main() {
+    // Init the ticker with the address of the function (toggle_led) to be attached and the interval (100 ms)
+    toggle_led_ticker.attach(&toggle_led, 0.1);
+    while (true) {
+        // Do other things...
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r d9ec23dd131e mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 08 12:18:12 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file