import processing.serial.*; Serial port; // Create object from Serial class int sensorValue; // Data received from the serial port void setup() { size(600, 600); noStroke(); // List all the available serial ports in the output pane. // I use port #9. println(Serial.list()); // Make sure to open port 9 the same speed Arduino is using (9600bps) port = new Serial(this, Serial.list()[9], 9600); } void draw() { if (0 < port.available()) { // If data is available to read, sensorValue = port.read(); // read it and store it in val } background(0); // Clear background line(40,sensorValue/.4,560,sensorValue/.4); // Draw a line with Y value according to sensor stroke(0, 100, 139); // Set color strokeCap(SQUARE); // Set cap style strokeWeight(400/(sensorValue+1)); // Set weight with the value reading }