I have a question concerning serial communication: I have a joystick connected to a PC which I would like to send the input to my Arduino UNO, up to now I can get all the joystick information to Serial, my question is how can distinguish data coming to the Arduino? For example, the joystick has 4 axes, how to send data via Serial and know which axis does the data belong to ?
I am using Qt and the serial communication function used to write on the serial, expect a QByteArray( QByteArray can be used to store both raw bytes (including '\0's) and traditional 8-bit '\0'-terminated strings ) so i can't really send a struct(only QByteArray or Strings)
Okay! I will have a look. One last thing : is it normal that i can't use the Serial Monitor while i am receiving data ? Is there a way to counter this ?
You need to sync the arduino with the incoming messages. That's why I suggested the "<" and ">" - they can be used for that purpose. Otherwise, the Arduino could start receiving part way through a message and it wouldn't make sense.
So your arduino code would wait for a "<", then the next character would be the axis/joystick channel. Then there would be the comma (you could forget the comma if the channel will always be a single character. Then you can use Serial.parseInt() to read the value. Finally there would be the ">" markling the end of the message which you can discard.
If you have your PC program using QT connected to the usb serial port of the Arduino Uno and its onboard usb>ttl converter, you can not connect the monitor to that same port.
You should be able to connect a second USB serial device using a separate usb to ttl converter connected to pins with a software serial instance.