Trying to open Images with jSon Object shows unreliable behavior

I don’t know anything about what you’re trying to do, but even I can tell that the end of your processing code has a few things that are probably ruining the whole thing

here’s the modified version,
https://pastebin.com/7CdGFFXF

since the block of code at the end is running on a loop, you need to not only be changing the bool variables to true, but also back to false if they are deemed false in the next iteration of the loop.

you also have an if statement that depends on the other if statements all returning true:

if (LimitSwitchHorizontalAxisReached && LimitSwitchRotaryAxisReached && LimitSwitchVerticalAxisReached) {
  image(imgGreen, 550, 965);
} else {
  image(imgRed, 550, 965);
}

This needs to be moved to the end of the block of if statements, in case all the other if statements return true in the 1st iteration of the loop. If you don’t do this, it will take until the 2nd iteration of the loop to register that all the values are true & the code can be executed.

I hope this fixes your issue, because that’s as far as my little knowledge goes.