Problem with while loop in arduino/pixy2 code

This is the piece of code that i’m having trouble with:
image

The problem is when the statement is true, only the top if statement would work. even if “35” and"36" is the contents of the serial port (arduino), nothing would print. only “Target on right” if that statement is true.

Here is the arduino code:

For more info please feel free to ask. I will respond pretty quick.

I expect readString() to read the next string from the serial port. What happens if you store it in a local variable like this?

while (arduino.getBytesReceived() > 0) {
  String message = arduino.readString();
  if (message.equals("35") {
    System.out.println("Target on right!");
  }
  // etc
}

Your a GOD! Thank you soooo much!
Here was the result:
image

Glad to hear it was a simple fix :slight_smile: