title: How do I get rid of NullPointerException in Processing?
body: <p>I have connected my arduino code serially to processing. I get a run time error that says NullPointerException in Processing.</p>
  
   
  
  <pre class="lang-java prettyprint-override"><code>import processing.serial.*;
  
  Serial myPort;
  String val ;
  int[] colour_val  ;
  
  
  void setup(){
  
     size(500,500);
     String portName = Serial.list()[0];
     myPort = new Serial(this, portName, 9600);
  }
  
  void draw(){
     if (myPort.available() &gt;0){
  
        val = myPort.readStringUntil('\n');
     }
     if (val != null){
        append(colour_val,val);
        for ( float v : colour_val)
           background(v);
     }
  }  
  </code></pre>