We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello!!
Here I have some code there I read serial from an Arduino and split it with the "split()" function. When I in this case have split it in two then I try to rename it to another name and trying to print it put with the new name, then just one work. If I print it out with the split name that in this case is (a[0] or a[1]) then it work just fine. put not with the new name (val1 and val2). So what is wrong?? Code is under. :)
PS: Sorry for my bad English :)
Code:
import processing.serial.*;
int end = 10;
String serial;
Serial port;
void setup() {
port = new Serial(this, Serial.list()[0], 9600);
port.clear();
serial = port.readStringUntil(end);
serial = null;
}
void draw() {
while (port.available() > 0) { //as long as there is data coming from serial port, read it and store it
serial = port.readStringUntil(end);
}
if (serial != null) {
String[] a = split(serial, ',');
int val1 = int(a[0]);
int val2 = int(a[1]);
println(val1);
println(val2);
}
}
Answers
Wild guess often working with serial:
Aha!!! Thanks a lot!!
Hello again the ".trim" did`n work :(
Hello, could you add println(serial); after if(serial! = null) And tell us the console output to let us check the format of the incoming data