I am using Arduino and Processing. I am trying to send a string from the Arduino to Processing
void serialDataOutput() {
dataString = "";
for (int i = 2; i <= 13; i++) {
if (digitalRead(i) == HIGH) {
dataString.concat(i);
dataString.concat(",1/");
} else {
dataString.concat(i);
dataString.concat(",0/");
}
}
//output "2,0/3,0/4,0/5,0/6,0/7,0/8,1/9,1/10,1/11,1/12,1/13,0";
Serial.write(dataString);
This is the code I have for generating the string, and an example output in the serial terminal.
However, in Processing, I am trying to get this string like this:
while (myPort.available() > 0) {
rawInput = myPort.readString();
println(rawInput);
myPort.clear();
}
This gives an output like this:
2,0/3,0
/4,0/5,0/6,0/7,0
/8,1/9,1/10,1/11
,1/12,1/13,1
It is broken up over multiple lines. I need the input in processing exactly how it was sent from Arduino.
How do I do this?