Null Pointer Exception with Arduino Communication

this other example using switch case

processing side


import controlP5.*;
import processing.serial.*;
 
ControlP5 cP5a;
ControlP5 cP5b;
 
Serial arduino;
 
void setup() {
  size(350,120);
 printArray(Serial.list());
 
  arduino = new Serial(this, Serial.list()[0], 9600);
 
  cP5a = new ControlP5(this);
  cP5a.addSlider("CYCLE_TIME", 999, 1999,999, 10, 10, 255, 35);
  cP5b = new ControlP5(this);
  cP5b.addSlider("PULSE", 55, 455, 55, 10, 55, 255, 35);
}
 
void draw()  {
  background(0);
 
  }
 
void controlEvent(ControlEvent theEvent) {
  if(theEvent.isController()) {
 
 print("control event from : "+theEvent.getController().getName());
 println(", value : "+theEvent.getController().getValue());
 
 if(theEvent.getController().getName()=="CYCLE_TIME") {
   int val1 = int(theEvent.getController().getValue());
   arduino.write("a" + val1+"\n");
 
 }
 
 if(theEvent.getController().getName()=="PULSE") {
   int val2 = int(theEvent.getController().getValue());
   arduino.write("b" + val2+"\n" );
   }
  }
}

Arduino side

void loop() {  
  
 
  
     if (Serial.available() >= 2)
 
  {
    int value2;
    char command = Serial.read();
    switch (command)
    {
    case 'a': value2 = Serial.parseInt();
      CYCLE_TIME = value2;
      break; 
     
 {

    case 'b': value2 = Serial.parseInt();
     TX_PULSE = value2;
       
   break;
        }