import processing.serial.*; Serial myPort; PFont font; int currentSecond; int sensorValue = 0; int secondCounter = 0; int fileCounter = 0; String[] minuteBuffer = new String[60]; String lastReading = "0"; String lastFile = "n/a"; void setup() { size(200,120); framerate(10); myPort = new Serial(this, Serial.list()[0], 9600); font = loadFont("ArialMT-24.vlw"); textFont(font,24); currentSecond = second(); } void draw() { background(0); if(second() != currentSecond) { currentSecond = second(); getValue(); } if(secondCounter >= 60) { String fileName = "begin"; secondCounter = 0; if(fileCounter < 10) { fileName = new String("m000000" + fileCounter + ".txt"); } else if(fileCounter <100) { fileName = new String("m00000" + fileCounter + ".txt"); } else if(fileCounter <1000) { fileName = new String("m0000" + fileCounter + ".txt"); } else if(fileCounter <10000) { fileName = new String("m000" + fileCounter + ".txt"); } else if(fileCounter <100000) { fileName = new String("m00" + fileCounter + ".txt"); } saveStrings(fileName, minuteBuffer); fileCounter += 1; lastFile = new String(fileName); } text(lastReading,20,50); text(lastFile,20,80); } void getValue() { myPort.write(63); int inBytes[] = new int[myPort.available()]; for(int i=0; i