Arduino演習Communication/Graph用スケッチ
 標準のArduino演習Communication/Graph用スケッチはうまく動作しませんでした。
 修正後のArduino演習Communication/Graph用スケッチは以下となります。
// Graphing sketch
 import processing.serial.*;
 Serial myPort;        // The serial port
 int xPos = 1;         // horizontal position of the graph
 void setup ()
 {
   // set the window size:
   size(400, 300);
   // List all the available serial ports
   // if using Processing 2.1 or later, use Serial.printArray()
   println(Serial.list());
 
   // I know that the first port in the serial list on my mac
   // is always my  Arduino, so I open Serial.list()[0].
   // Open whatever port is the one you're using.
   myPort = new Serial(this, Serial.list()[4], 9600);
 
   // don't generate a serialEvent() unless you get a newline character:
   myPort.bufferUntil('\n');
 
   // set inital background:
   background(0);
 }
 
 void draw ()
 {
   if(myPort.available()>16 )//受信データが16バイト以上の場合
   {
     String inString = myPort.readString();//受信バッファを全部読む
     String[] s =splitTokens(inString);//文字列をスペース、改行等で分離
     inString = trim(s[1]);//2番目のデータの空白を除去
     float inByte = float(inString);//実数型に変換
     inByte = map(inByte, 0, 1023, 0, height);
     stroke(127,34,255);//線の色
     line(xPos, height, xPos, height - inByte);//線を引く
     if (xPos >= width)
     {
       xPos = 0;
       background(0);
     }
     else
     {
       xPos++;
     }
   }
 }