Processing serial.available issue

One thing that jumps out as being a problem for me right away is the call to delay(10000); in your processing code. You simply don’t need it - please remove it. The fact that you’re checking for the next serial data being available is what “causes a delay” in your Processing code.

next, I would move ALL processing of your data INSIDE the conditional statement that checks to see if there is data. Like so:

void draw() {
  if ( myPort.available() > 0) {  // Is > 0 the right check here?
    val = myPort.readStringUntil('\n'); // read it and store it in val
    if (val != null) {
      a = split(val, ','); 
      println(a[0]);
      println(a[1]);
      function();  // TODO: Seriously, call this something else, like send_data()?
      // val = null; // Hrm. Might not need this.
    }
  } 
}

Anyway, try it with this draw function and see if that helps…?

3 Likes