Blink using threads

Files at this revision

API Documentation at this revision

Comitter:
lmottola
Date:
Thu Nov 08 12:37:42 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-os.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r f6371c0a2f6f main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 08 12:37:42 2018 +0000
@@ -0,0 +1,23 @@
+#include "mbed.h"
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+Thread thread;
+
+void led2_thread() {
+    while (true) {
+        led2 = !led2;
+        wait(1);
+    }
+}
+
+int main() {
+    // Create a thread to execute the function led2_thread
+    thread.start(led2_thread);
+    // Now led2_thread is executing concurrently with main at this point
+
+    while (true) {
+        led1 = !led1;
+        wait(0.5);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f6371c0a2f6f mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Thu Nov 08 12:37:42 2018 +0000
@@ -0,0 +1,1 @@
+https://github.com/armmbed/mbed-os/