Thomas Cauwelier / Mbed 2 deprecated visible_light_communication

Dependencies:   SoftSerial SDFileSystem mbed wave_player

Revision:
13:c111ea1c5990
Parent:
12:a070de571ea1
Child:
14:e29cca7e64b2
--- a/main.cpp	Tue May 09 21:39:59 2017 +0200
+++ b/main.cpp	Tue May 09 22:01:09 2017 +0200
@@ -72,15 +72,36 @@
 //    }
 //}
 
+void client(){
+    SoftSerial s(NC,p17);
+    s.baud(9200);
+    while (true) {
+        while (!s.readable());
+        char c = (char) s.getc();
+        printf((const char *) c);
+    }
+}
+
+void relay(){
+    SoftSerial s(p17,NC);
+    s.baud(9200);
+    while (true){
+        wait(1);
+        s.putc(0b00110101);
+    }
+}
+
 #define RELAY 1
 
+Serial usb(USBTX,USBRX);
+
 int main() {
-    SoftSerial s(LED1,NC);
-    s.baud(1);
-
+    usb.baud(115200);
     if (RELAY){
-        s.putc(0b00110101);
+        printf("relay\r\n");
+        relay();
     } else {
-
+        printf("client\r\n");
+        client();
     }
 }
\ No newline at end of file