I encountered another problem when communicating with Arduino. I want to send raw data. On the Processing side I prepare them as a String and send them to Arduino via Serial. Using
void writeToArduino(String whatToWrite) {
Arduino.write(whatToWrite);
}
mangles the data for some reasons. For example it always sends 0x3F instead of 0xFF. But other chars are sent correctly. To get correct data I need to do
void writeToArduino(String whatToWrite) {
for (int i=0; i<whatToWrite.length(); i++) Arduino.write(whatToWrite.charAt(i));
}
Why? String is not “an array of chars?”