// Example by Tom Igoe import processing.serial.*; // global variables int inByte; Serial myPort; // The serial port int dataCount=0; int x=0; int lastX, lastByte; 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(600, 400); stroke(255); background(0); } void draw() { } void serialEvent(Serial myPort) { lastByte = inByte; lastX = x; inByte = myPort.read(); println(inByte); dataCount++; //println("data count: " + dataCount); x++; if(x>400) { background(0); x=0; }; line(lastX, 400-lastByte, x, 400-inByte); }