Listing 6. Example of a Serial Client Sketch /*Client for Serial communication*/ /* Amit Saha */ import processing.serial.*; Serial myPort; // The serial port // initial variables: int i = 1; // counter char inData; void setup () { size(400, 350); // window size // List all the available serial ports println(Serial.list()); // Pick up the first port, since I usually have // just the Arduino connected. // Make sure the correct port is selected here. myPort = new Serial(this, Serial.list()[0], 9600); myPort.clear(); // set initial background: background(255); } void draw () { myPort.write(4); //myPort.write(5); if (myPort.available() > 0) { inData = (char)myPort.read(); // Typecast it to the corresponding // character for the // ASCII value serialEvent(); } } void serialEvent () { System.out.println(inData); }