Problems with serial communication with arduino

edited February 2015 in Arduino

Hello, I'm trying to make a drum software that receives data from the arduino Uno and triggers the respective drum beat. the sketch works fine for some time, after which it gives the error Array out of Bounds.

while(arduino.available() >0)
  {
    v = arduino.readString();
    println(v);
    val = int(split(v, ','));
    if(val[0] == 1) kick1.trigger();
    if(val[1] == 1) snare.trigger();
    //arduino.flush();
  }

This part is placed within void draw(). Iv tried using the void serialEvent function, but that gives the error: disabling serialEvent(). After fiddling around i noticed that with the serial read in the draw function it works, but some times it doesnt read the entire packet of data. And sometimes enters the loop but fails to receive any data. My best guess is it is a timing issue, but I have no clue how to fix it. Any help would be appreciated. Thanks in advance.

Sign In or Register to comment.