Hi. I`m using
processing.serial.*; library to connect my processing programm with arduino via serial port. Arduino sends to serial 3 values, every value starts from the new line like this:
X
Y
Z
I`ve used serial monitor to check, that Arduino works correct. But my code cannot read this lines correctly: sometimes it get all three values, sometimes values are missing. Here the arduino code:
Serial.println(h);
Serial.println(l);
Serial.println(temp);
delay(10000);
And here the processing code:
while (myPort.available() > 0) {
String hum = myPort.readStringUntil(lf);
delay(50);
String lum = myPort.readStringUntil(lf);
delay(50);
String temp = myPort.readStringUntil(lf);
...}
I`ve tried to put
delay to fix the problem, but it doesn`t help me. How can I fix it? I think I`m reading strings wrong, but I can`t understand, how to fix it.