Program to demonstrate lighting an led via a command line command

Dependencies:   LPS331_I2C

Revision:
0:f7d9662c6d11
Child:
1:48e24393d6d9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Sep 22 13:41:56 2021 +0000
@@ -0,0 +1,44 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2019 ARM Limited
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include "mbed.h"
+#include "platform/mbed_thread.h"
+#include <string.h>
+
+
+// Blinking rate in milliseconds
+#define BLINKING_RATE_MS                                                    500
+
+Serial pc(USBTX, USBRX); // tx, rx
+
+int main()
+{
+    char cmd[80];
+    char ch;
+    unsigned char index = 0;
+
+    // Initialise the digital pin LED1 as an output
+    DigitalOut led(LED1);
+    pc.printf("L432> ");    
+    while (true) {
+        
+        ch = pc.getc();
+        index = 0;
+        while ((ch != '\n') && (ch != '\r')) {
+            pc.putc(ch);
+            cmd[index++] = ch;
+            ch = pc.getc();
+        }   
+        cmd[index] = 0;
+        if (!strcmp(cmd,"lon")) {
+            led = 1;
+        }   
+        else if (!strcmp(cmd,"lof")) {
+            led = 0;
+        }
+        pc.printf("\n\r",cmd);
+        pc.printf("L432> ");
+    }
+}