// Read data from the serial port and assign it to a variable. Set the fill a // rectangle on the screen using the value read from a light sensor connected // to the Wiring or Arduino board import processing.serial.*; Serial port; // Create object from Serial class int val; // Data received from the serial port PImage img; // Background image void setup() { size(1366,768); noStroke(); frameRate(10); // Run 10 frames per second String portName = Serial.list()[1]; //retrieving data from COM14 port = new Serial(this, portName, 115200); // Open the port that the board is connected to and use the same speed (9600 bps) img = loadImage("background.jpg"); //loading the background image } void draw() { if (port.available()>0) { // If data is available to read val = port.read(); // read it and store it in val } if (val != 0) { background(img); fill(204, 102, 0); // Set fill color with the value read textSize(100); //val = val.replace('\n', ' '); circle(200, 400, val); } else{ println("null");} }