Julius Bernth / Mbed OS mbed-os-example-mbed5-blinky
Revision:
0:2fc04988cde3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Nov 19 22:29:37 2021 +0000
@@ -0,0 +1,54 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2019 ARM Limited
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include "mbed.h"
+#include "platform/mbed_thread.h"
+
+
+// Blinking rate in milliseconds
+#define BLINKING_RATE_MS                                                    500
+
+Serial pc(USBTX, USBRX); // tx, rx
+Thread one;
+Thread two;
+Thread three;
+
+void funcOne(){
+    while(1){
+        pc.printf("one \r\n");
+        thread_sleep_for(500);
+    }
+}
+
+void funcTwo(){
+    while(1){
+        pc.printf("two \r\n");
+        thread_sleep_for(1000);
+    }
+}
+
+void funcThree(){
+    while(1){
+        //one.join();
+        two.start(funcTwo);
+        thread_sleep_for(4000);
+        
+        one.start(funcOne);
+        //two.join();
+        thread_sleep_for(4000);
+    }
+}
+
+int main()
+{
+    // Initialise the digital pin LED1 as an output
+    DigitalOut led(LED1);
+    pc.printf("Hi there \r\n");
+    three.start(funcThree);
+    while (true) {
+        led = !led;
+        thread_sleep_for(BLINKING_RATE_MS);
+    }
+}