import processing.serial.*; Serial myPort; int X1, X2, Y1, Y2; float h, v; void setup() { printArray(Serial.list()); myPort = new Serial(this, Serial.list()[3], 19200); } void draw() { byte[] inBuffer = new byte[8]; while(myPort.available() > 0) { myPort.readBytesUntil(0x0a); myPort.readBytes(inBuffer); X1 = (inBuffer[1] << 8) + inBuffer[0]; X2 = (inBuffer[3] << 8) + inBuffer[2]; Y1 = (inBuffer[5] << 8) + inBuffer[4]; Y2 = (inBuffer[7] << 8) + inBuffer[6]; //h = (X1-X2)/(X1+X2); //v = (Y1-Y2)/(Y1+Y2); println("X1: " + hex(X1) + "\tX2: " + hex(X2) + "\tY1: " + hex(Y1) + "\tY2: " + hex(Y2)); //println("H Angle: " + h + "\tV Angle: " + v); } }