This is single way communication with the PC

Dependencies:   mbed

Revision:
0:5d7b0ed9dcc9
Child:
1:dad12410fd2d
diff -r 000000000000 -r 5d7b0ed9dcc9 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Dec 04 19:19:19 2016 +0000
@@ -0,0 +1,21 @@
+#include "mbed.h"
+ 
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+ uint8_t data;
+Serial pc(USBTX, USBRX);
+ 
+void call() {
+    // Note: you need to actually read from the serial to clear the RX interrupt
+    data = pc.getc();
+    printf("%c\n", data);
+    led2 = !led2;
+}
+ 
+int main() {
+    pc.attach(&call);
+    while (1) {
+        led1 = !led1;
+        wait(0.5);
+    }
+}
\ No newline at end of file