Using the “Simple Write serial example” in my Processing 3.5.3…
Consider setting the “state” and only sending data if there is a “state” change.
if (mouseOverRect() == true && state != 'H')
{
// Do something if last state was not 'H' ( 'L' is the other state in example)
state = 'H';
}
This worked for me and I only send data once when mouse is over the rectangle.
You will have to complete the rest of the code and also declare state variable and initial state.

