import processing.serial.*;
Serial myPort; // The serial port
void setup() {
// List all the available serial ports
printArray(Serial.list());
// Open the port you are using at the rate you want:
myPort = new Serial(this, "/dev/ttyUSB2", 9600);
size(1000, 600);
frameRate(30);
noStroke();
}
void draw() {
background(220);
while (myPort.available() > 0) {
int inByte = myPort.read();
int inByte1 = myPort.read();
int inByte2 = myPort.read();
int val = (inByte+inByte1+inByte2)/3;
println(val);
fill(100);
rect(200, 300, 100+val*2, 100);
}
}