a

Files at this revision

API Documentation at this revision

Comitter:
tmnam0
Date:
Thu Nov 19 06:59:11 2020 +0000
Commit message:
a

Changed in this revision

README.md Show annotated file Show diff for this revision Revisions of this file
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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Thu Nov 19 06:59:11 2020 +0000
@@ -0,0 +1,4 @@
+#Serial_LEDControl
+
+MIRRORED FROM MASTER EXAMPLE SNIPPETS REPOSITORY: mbed-os-examples-docs_only.
+ANY CHANGES MADE DIRECTLY TO THIS REPOSITORY WILL BE AUTOMATICALLY OVERWRITTEN.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 19 06:59:11 2020 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2006-2020 Arm Limited and affiliates.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include "mbed.h"
+
+static BufferedSerial pc(USBTX, USBRX); // tx, rx
+PwmOut led(LED1);
+
+float brightness = 0.0;
+
+int main()
+{
+    char msg[] = "Press 'u' to turn LED1 brightness up, 'd' to turn it down\n";
+    char *c = new char[1];
+    pc.write(msg, sizeof(msg));
+
+    while (1) {
+        pc.read(c, sizeof(c));
+        pc.write(c, sizeof(c));
+        if ((*c == 'u') && (brightness < 0.5)) {
+            brightness += 0.01;
+            led = brightness;
+        }
+        if ((*c == 'd') && (brightness > 0.0)) {
+            brightness -= 0.01;
+            led = brightness;
+        }
+    }
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Thu Nov 19 06:59:11 2020 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#9a8c9e2c297f64c805698d72cd541ff3cd7fe538
\ No newline at end of file