import processing.serial.*; String buff = “”; int val = 0; int NEWLINE = 10; Serial port; void setup(){ port = new Serial(this, Serial.list()[0], 9600); // Use the first available port } void draw(){ while (port.available() > 0) serialEvent(port.read()); //look for data background(val); //change background clr based on input data } void serialEvent(int serial) { if(serial != NEWLINE) { buff += char(serial); //add on bytes until a newline is found } else { buff = buff.substring(0, buff.length()-1); val = Integer.parseInt(buff)/4; // Parse the String to int println(val); buff = “”; // Clear the value of “buff” } }