import processing.serial.*; Serial myPort; // Create object from Serial class int tmp; void setup() { size(255,255); //make our canvas 200 x 200 pixels big String portName = Serial.list()[0]; //change the 0 to a 1 or 2 etc. to match your port myPort = new Serial(this, portName, 9600); } void draw() { if (mousePressed == true) { //if we clicked in the window tmp=mouseX; myPort.write(tmp); // println(tmp); } }