// Example by Tom Igoe import processing.serial.*; import java.lang.Math; // constants int MINSIZE = 100; int MAXSIZE = 640; // global variables int inByte; int currSize = 300; Serial myPort; // The serial port void setup() { // List all the available serial ports println(Serial.list()); // I know that the first port in the serial list on my mac // is always my Keyspan adaptor, so I open Serial.list()[0]. // Open whatever port is the one you're using. myPort = new Serial(this, Serial.list()[1], 57600); size(1200, 640); noStroke(); fill(0); background(255); rectMode(CENTER); } void serialEvent(Serial myPort) { inByte = myPort.read(); println(inByte); //currSize+=(inByte/100); //if(currSize>height)currSize=height; } //void loop() //{ // background(255); //currSize = int(constrain(currSize-Reciprocal_Logarithmic_model(currSize), MINSIZE, MAXSIZE)); //println(currSize); // rect(width/2, height/2, currSize, currSize); //} /*float Reciprocal_Logarithmic_model(float x_in) { //reciprocal log model from zunzun.com //fit to data points // 100, 0 // 800, 40 float temp; temp = 0.0; // coefficients double a = -4.0025866201659571E+06; double b = 5.9877623536443559E+05; temp = (float)(1.0 /(a + b*Math.log(x_in))); return temp; } */