// Program draws a black square in the middle of the screen. // It reacts to multiple key-presses, growing. // From reactive_square_lg // Includes import processing.serial.*; Serial port; // Constants int i; int lf = 10; long last; void setup() { size(800, 600); rectMode(CENTER); noStroke(); fill(0); background(255); // Print a list in case COM1 doesn't work out println("Available serial ports:"); println(Serial.list()); port = new Serial(this, Serial.list()[0], 9600); port.bufferUntil(lf); i=0; } void draw() { if(millis()-last>5000) { // background(255); i=0; } } void serialEvent(Serial p) { String inString = (port.readString()); print(inString); i=(i+1)%53; float val = parseFloat(inString); fill(val/1024.0*255); rect(i*15, height, 15,val/1024.0*-1*width); last=millis(); }