You can do that! Nice to see you putting a lot of thought into this.
You will have to frame the data string you are sending correctly and terminate with a ‘/n’ (in my example.
Example of received string only:
// Trim and split an data string Rx from Arduino.
// v1.0.0
// GLV 2020-MM-DD
void setup()
{
background(0);
size(400, 500);
// Data packet received from Arduino:
// t1, d1, t2, d2, ... t=time, d=data
String inString = "1000,250,1100,300,1200,375,1300,380,1400,375,1500,300,1600,250,1700,200\n"; // '\n' is a linefeed character
print(inString);
inString = inString.trim(); //Works!
inString = trim(inString); //Works!
print(inString);
println("end"); //confirms that '/n' was removed!
println();
String[] list = split(inString, ',');
printArray(list);
int [] data = int( split(inString, ',') );
printArray(data);
stroke(255, 255, 0);
strokeWeight(5);
for(int i = 0; i< data.length; i+=2)
{
point((data[i]-1000)/5, data[i+1]);
}
}
Next step I leave with you.
:)