I provided examples for you.
I modified your code as follows and it works with the Arduino example I provided:
void serialEvent(Serial myPort) {
// read the serial buffer:
String myString = myPort.readStringUntil('\n');
if (myString != null) {
myString = trim(myString);
println(myString);
String sensors[] = split(myString, ',');
printArray(sensors);
// Process data from array here.
}
}
How you choose to code this is up to you.
This is your project.
This is output:
https://processing.org/reference/printArray_.html
Notice the quotes?
That is because it is a String array.
I converted “1” or “0” received to an int (see my previous example) so I could compare int data (0 or 1) in my code.