mbed OS Blinky LED HelloWorld

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Revision:
67:1885193045fb
Parent:
29:0b58d21e87d6
--- a/main.cpp	Fri Oct 04 03:03:14 2019 +0000
+++ b/main.cpp	Tue Sep 01 06:24:37 2020 +0000
@@ -1,12 +1,25 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2019 ARM Limited
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
 #include "mbed.h"
 
-DigitalOut led1(LED1);
+
+// Blinking rate in milliseconds
+#define BLINKING_RATE     500
+
 
-// main() runs in its own thread in the OS
-int main() {
+int main()
+{
+#ifdef MBED_MAJOR_VERSION
+    printf("Mbed OS version %d.%d.%d\r\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
+#endif
+    // Initialise the digital pin LED1 as an output
+    DigitalOut led(LED1);
+
     while (true) {
-        led1 = !led1;
-        wait(0.5);
+        led = !led;
+        ThisThread::sleep_for(BLINKING_RATE);
     }
-}
-
+}
\ No newline at end of file