I want to send the state of my left wheel encoders along with the state of my right wheel encoders at the same time. For example if my arduino serial.writes that the left wheel is in state 1 and my right wheel is in state 3, I want to read it in Unity. However since Unity is only reading from one USB port, it gets confused. What I tried to do is write a binary value in the arduino IDE. Example;
Value = B0101; //in binary
Serial.write(Value); // this is in arduino, basically the first two binary values represent the left encoders’ (2 of them) HIGH or LOW state and the last two binary values represent the right encoders’(also 2 encoders) HIGH or LOW state.
I would like to know how I could read it in Unity so that a change in the first two bits means one thing and a change in the last two bits means another. Also, I tried to do it by writing two separate scripts in Mono, but I get a I/O Exception error. I believe unity can’t read from the same port by two separate scripts at the same time. Correct me if I’m wrong, and do you have any solution suggestions?