import processing.serial.*; Serial arduino; void setup() { size(700, 600); println(Serial.list()[0]); String portName = Serial.list()[0]; //change the 0 to a 1 or 2 etc. to match your port arduino = new Serial(this, portName, 9600); } void draw() { if (mousePressed == true) { if (mouseX >= 0 && mouseX <= 200){ arduino.write("1c255w"); } else if (mouseX >= 200 && mouseX <= 400){ arduino.write("2c255w"); } else if (mouseX >= 400 && mouseX <= 600){ arduino.write("3c255w"); } else if (mouseX >= 600 && mouseX <= 700){ arduino.write("1c255w"); arduino.write("2c255w"); arduino.write("3c255w"); } } else { arduino.write("1c0w"); arduino.write("2c0w"); arduino.write("3c0w"); } fill(255, 0, 0); rect(0, 0, 200, 600); fill(0, 255, 0); rect(200, 0, 200, 600); fill(0, 0, 255); rect(400, 0, 200, 600); fill(255, 255, 255); rect(600, 0, 100, 600); }