I am using Processing to send an array of bytes to an Arduino card via a serial port. I have a strange problem where the Arduino doesn't seem to read the array "in sync" - the byte elements appear shifted to the Arduino code.
For example, from Processing I send array:
array = [0, 1, 2, 3, 4];
and the Arduino could read it as:
array = [2, 3, 4, 0, 1];
This problem appears at random - about 1/3 times I try, and the shift is always random as well. When it works it continues to work for the duration of the session, until i restart the connection.
Have anyone else encountered similar problems? Do you have any suggestions as of how to fix this problem?
Regards, Tobias