mousePressed not updating in while loop

Found the solution to my problem.

I had assumed mousePressed works like an interrupt when a button is clicked but it actually polls between each draw() loop for a click, which is why mousePressed never updates within a loop.

My original intention was to send a command to a waiting arduino with a mouse click. Since I can’t while loop indefinitely I replaced the while with an if(waiting state) and it works properly now.

1 Like