Control an LED from a computer via the serial port

Dependencies:   mbed

Revision:
0:da809d54f2ce
Child:
1:c064570d8b35
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PhysicalPixel.cpp	Sun Jun 01 03:41:48 2014 +0000
@@ -0,0 +1,27 @@
+#include "mbed.h"
+
+// Global variables
+DigitalOut led(LED1);
+Serial pc(USBTX, USBRX);
+
+// Function prototypes
+void handleInput(char in);
+
+// Main function
+int main() {
+    while(true) {
+        if(pc.readable()) {
+            char c = pc.getc();
+            handleInput(c);
+        }
+    }
+}
+
+// Input handler
+void handleInput(char in) {
+    if(in == 'H') {
+        led = 1;
+    } else if(in == 'L') {
+        led = 0;
+    }
+}
\ No newline at end of file