import processing.serial.*; Serial inputPort; String input = ""; void setup() { size(500, 500); //Just shows all the serial connections in case other devices show up for(int i=0; i < Serial.list().length; i++) println(i + " " + Serial.list()[i]); // [2] usually works, but sometimes you need a different number // -> check the list in the debugger String port = Serial.list()[2]; inputPort = new Serial(this, port, 9600); } void draw() { fill(0); rect(0, 0, width, height); fill(255); text("Current Input: " + input, 100, 100); if (inputPort == null) text("NO CONNECTION", 100, 80); else text("CONNECTED", 100, 80); } void serialEvent(Serial p) { String result = ""; String temp = ""; if (inputPort.available() > 0) { temp = inputPort.readStringUntil('\n'); if (temp != null) result = trim(temp); } input = result; }