Echo back characters you type based in https://mbed.org/handbook/SerialPC example

Dependencies:   mbed

Fork of FRDM_serial_echo_demo by felipe manrique

Revision:
1:675b841fe7dc
Parent:
0:806d4eb73e1e
--- a/main.cpp	Sat Oct 05 19:10:27 2013 +0000
+++ b/main.cpp	Sun Apr 27 07:21:21 2014 +0000
@@ -1,10 +1,23 @@
-#include "mbed.h"              
+#include "mbed.h"
  
-Serial pc(USBTX, USBRX);
+Serial pc(USBTX, USBRX); // tx, rx
+PwmOut led(LED1);
+ 
+float brightness = 0.0;
  
 int main() {
-    pc.printf("Echoes back to the screen anything you type\n");
+    pc.printf("Press 'u' to turn LED1 brightness up, 'd' to turn it down\n");
+ 
     while(1) {
-        pc.putc(pc.getc());
+        char c = pc.getc();
+        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