UART array transmission test code. (Receive)

Dependencies:   mbed

Revision:
0:c16e741bd863
Child:
1:adb918553885
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Feb 19 12:40:21 2018 +0000
@@ -0,0 +1,54 @@
+#include "mbed.h"
+
+Serial device2(p9,p10);  //tx,rx
+BusOut myleds(LED4, LED3, LED2, LED1);
+
+int buffer2[8];
+int temp2;
+
+int led1;
+int led2;
+int led3;
+int led4;
+
+int main()
+{
+
+    myleds = 0;
+
+    device2.baud(19200);
+
+    while(1) {
+        temp2 = device2.getc();
+        if (temp2 == 1) {
+            for (int i=0; i<5; i++) {
+
+                buffer2[i] = device2.getc();
+                temp2 = buffer2[i];
+                if ((temp2 == 1)&&(i == 0)) {
+                    led1 = 1;
+                } else if (i == 0) {
+                    led1 = 0;
+                }
+                if ((temp2 == 1)&&(i == 1)) {
+                    led2 = 2;
+                } else if (i == 1) {
+                    led2 = 0;
+                }
+                if ((temp2 == 1)&&(i == 2)) {
+                    led3 = 4;
+                } else if (i == 2) {
+                    led3 = 0;
+                }
+                if ((temp2 == 1)&&(i == 3)) {
+                    led4 = 8;
+                } else if (i == 3) {
+                    led4 = 0;
+                }
+
+            }
+            myleds = led1 + led2 + led3 + led4;
+        }
+    }
+
+}
\ No newline at end of file