The last line of code gives me an error.
float[] val = {}; -> float[] val = float[2];
"Error on ‘.class’ "
How do you propose I read the serial values and store each one separated by tsv onto my array?
Should I put the splitTokens withing draw? It doesn’t necessarily have to be in serialEvent right?
Edit: I tried to do something with this and it’s a null error:
import processing.serial.*;
String index;
float[] val;
Serial port;
float x, y;
float px = 600;
float py = 350;
void setup() {
size(200, 200);
noLoop();
new Serial(this, "COM12", 115200).bufferUntil('\n');
}
//void serialEvent(final Serial port) {
// val = float(splitTokens(port.readString()));
//}
void draw() {
while (port.available() > 0) {
String input = port.readString(); //takes serial input from Arduino
val = float(splitTokens(input)); //assuming that all values until \n are caputured, split into array
x = val[0];
y = val[1];
line(px, py, x + px, y + py); //draw line
px = x;
py = y;
}
}