Trying to get an Arduino report Data to Processing with a sketch which sends a String (“abcd”) every second.
On Processing side there is:
import processing.serial.*;
Serial SerPort;
String rx = "";
void setup () {
size (480, 320);
println ( Serial.list() );
SerPort = new Serial(this, "COM2", 9600);
SerPort.bufferUntil('\n');
}
void draw () {
if ( SerPort.available () > 0 ) {
rx = SerPort.readStringUntil ('\n');
}
rx = trim(rx);
println(rx);
}
As result there are some 20 “nulls” with the occasional “abcd” hidden in between. The Trim-command didn’t remedy.
Any hint welcome.
be well, Thomas