Todd Dale
/
Serial_Comms_Receive
UART array transmission test code. (Receive)
Diff: main.cpp
- Revision:
- 1:adb918553885
- Parent:
- 0:c16e741bd863
- Child:
- 2:6f9b37d8b6aa
diff -r c16e741bd863 -r adb918553885 main.cpp --- a/main.cpp Mon Feb 19 12:40:21 2018 +0000 +++ b/main.cpp Mon Feb 19 13:09:08 2018 +0000 @@ -6,6 +6,8 @@ int buffer2[8]; int temp2; +char matrix2[2][2]; + int led1; int led2; int led3; @@ -21,31 +23,33 @@ while(1) { temp2 = device2.getc(); if (temp2 == 1) { - for (int i=0; i<5; i++) { + for (int i=0; i<2; i++) { + for (int j=0; j<2; j++) { - buffer2[i] = device2.getc(); - temp2 = buffer2[i]; - if ((temp2 == 1)&&(i == 0)) { - led1 = 1; - } else if (i == 0) { - led1 = 0; + matrix2[i][j] = device2.getc(); + temp2 = matrix2[i][j]; + if ((temp2 == 1)&&(i == 0)&&(j == 0)) { + led1 = 1; + } else if ((i == 0)&&(j == 0)) { + led1 = 0; + } + if ((temp2 == 1)&&(i == 0)&&(j == 1)) { + led2 = 2; + } else if ((i == 0)&&(j == 1)) { + led2 = 0; + } + if ((temp2 == 1)&&(i == 1)&&(j == 0)) { + led3 = 4; + } else if ((i == 1)&&(j == 0)) { + led3 = 0; + } + if ((temp2 == 1)&&(i == 1)&&(j == 1)) { + led4 = 8; + } else if ((i == 1)&&(j == 1)) { + led4 = 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; }