Processing 2 Arduino: Sending CSVs

Hello all, I have a list of values that I want to send from Processing to Arduino. The values would be formated like this:

"x:y" where x = port number on the Arduino Mega y = 1 or 0 (on or off - high or low) Example: "3:0,4:1,5:0" all the way to "52:1"

This list would be sent from processing at a speed of 15 frames per second.

I'm quite lost on the best way to read the values in Arduino. Actually I'm not even sure if this list would be the best solution to this. Any advice would be greatly appreciated.

Thanks in advance. Kind regards, LG

Will you always be sending all 50 port values each time? If so, it would be easier to just send 50 bits - 00010011101110....

Serial.print in the Processing program, and on the Arduino is all that's required. If the Serial transmission rate is high enough, and the processing requirements on the Arduino low enough, 15 frames a second is possible.

Could you please advise me on how to certify that the packs are in order? I'm afraid that if one drops, all the other will be out of sync and the program will go crazy. Should I do something like: "a01000010010...b" Starting with an "a" and ending with a "b". Thank you, LG

Any unique starting and ending character would work. Scan the stream available from, discarding anything until you find the start character. Then save everything until the end character, counting stored characters. If you got enough, use them. If not, start over.

Using bit shifting, you can send the 50 bits in 7 bytes, plus one byte for the start and end character, to minimize data sent and received, along with the chances of lost data.