Charles Tritt / Mbed OS Serial2RGB_21_v5
Revision:
7:a03687963ad4
Parent:
6:dcc4031025a6
--- a/main.cpp	Fri Sep 17 20:47:58 2021 +0000
+++ b/main.cpp	Sat Sep 18 01:45:02 2021 +0000
@@ -1,7 +1,5 @@
-#include "mbed.h"
-
 /*
-    Serial2RGB main by C. S. Tritt, Last revised 9/15/21 (v. 1.2)
+    Serial2RGB main by C. S. Tritt, Last revised 9/15/21 (v. 1.3)
 
     Toggles RGB LED junctions in response to serial input. Note input is case 
     sensive and known "commands" are r (toggle red), g (toggle green) and b 
@@ -25,7 +23,10 @@
 
 */
 
-// Construct resources.
+// Include mbed API/Library declarations.
+#include "mbed.h"
+
+// Construct resources (these are global).
 
 DigitalOut RedLED(D13); // Arduino Digital pin 13 on Nucleos.
 DigitalOut GrnLED(D14); // Arduino Digital pin 14.
@@ -36,15 +37,15 @@
 int main()
 {
 
-    RedLED = 0;  // Set pins to known state (junction on if active low).
+    RedLED = 0;  // Set pins to known state. This may be the default.
     GrnLED = 0;
     BluLED = 0;
-    char letter;  // Declare variable to hold recieved characters.
+    char letter;  // Declare a local variable to hold recieved characters.
 
     while(true) {  // Main (infinite) loop.
         if (pc.readable()) {  // Is there a character waiting? If so,
             letter = pc.getc();  // Get it.
-            pc.putc(letter);  // Echo it.
+            pc.putc(letter);  // Echo it to the terminal.
             if (letter == 'r') {  // Respond to known letters, ignore others.
                 RedLED = !RedLED;  // Toggle red.
             } else if (letter == 'g') {