Thanks!
Oops I, too, knew I was missing something ![]()
I’ll take the time to slowly read because often times I skim (idk it’s a natural thing I do). Proves to be ineffective with programming hehe
Will do
but maybe I’ll just replace the Arduino code parts to float. If we’re going for code efficiency, I guess I’ll change it to int
At the time I wrote this reply this is what I have so far (implementing your recent suggestions…)
import processing.serial.*;
Serial port;
float[] coords = new float [2];
float x, y;
float px = 250;
float py = 250;
void setup(){
size(500,500);
final String[] str = Serial.list(); //not sure why i need this but copied it anyway
printArray(str); //this one too
port = new Serial (this, "COM12", 115200);
port.bufferUntil('\n');
}
void draw(){
background(1);
//serialEvent(port);
//coords = float(splitTokens(port.readString()));
stroke(255);
x = coords[0];
y = coords[1];
line(px, py, x + px, y + py);
print(x);
print(y);
println(" ");
px = x;
py = y;
}
void serialEvent(final Serial port){
coords = float(splitTokens(port.readString()));
//redraw = true; //added just because it's on your model code
}
With a weird output
[code]
[0] “COM12”
0.00.0
…
0.00.0
0.00.0
ArrayIndexOutOfBoundsException: 0
[/code]:
TL:DR the end of the output has an error on it
It’s also not drawing anything