// This program shows how to read numbers in a human readable "ASCII" format from the Serial Port // Created 2013 by Felix Bonowski // This code is in the public Domain. import processing.serial.*; //the functionality for using the Serial Port lies in a speical library. This tells Processing to use it. Serial myPort; // Create a "serial port" object/variable. "Serial" is the type of the object (just like "int"), "myPort" is the name of the variable //this function gets called at the beginnign of the program void setup () { // Initialze Serial communication. There may be multiple serial ports on your computer, so we have to select one: String[] portNames=Serial.list();//Serial.list() returns an array of port names // if there is no serial port, quit with an error message if (portNames.length==0){throw(new IllegalStateException("There are no Serial ports on this computer!"));} println(portNames); //print them to the user // initialize the Serial port Object using the last name from the list and a Baudrate of 9600 myPort = new Serial(this, portNames[portNames.length-1], 9600); // Set up the screen: size(1024, 512); // set size of the window background(0);// set background color to black stroke(255); // set the color of things we draw to white // make the loop run as fast as it can so we dont loose any data frameRate(2000); } //this function is called continously, just as "loop" in arduino void draw () { // get data from the Serial Port float[] data=readLineFromSerial(myPort); //check if data was received... if (data.length>0) { println( "\ngot fresh data!"); } //or do something with all values: for(int i=0;i