Well, I was lost after the first 3 replies, however I think I can use an array and index the place of it
Like maybe:
float val[2];
int index = 0;
//given that we are already reading from serial port called "port"...
...
void func(){ //not sure which real function to put in the real code
input = port.readStringUntil('\n');
val[index] = input;
index = index + 1;
input = port.readStringUntil('\n');
val[index] = input;
index = index + 1;
if (index > 1){
index = 0;
}
pxval = val[0];
pyval = val[1];
}
...
//another external function here
void draw(){
background(1);
stroke(255);
line(pxval, pyval, val[0], val[1]);
}
Note: being new to Processing and coming from a slight Arduino background, I am still learning.
Another note: I had no time to read the reply you gave, as well as the whole question, due to me having a load of schoolwork. Apologies for any incompetence.
EDIT: I have read a bit of the link within the one you sent me:
I think within my arduino code I should output the accelerometer values with a [0] or [1] appended to it, and from there use readStingUntil. I hope this is solved; I will do some testing but for the meantime if there are any errors you can see, please get back to me
Thank you