Don’t use the mousePressed
boolean. Instead, use the mousepressed()
function.
The boolean is true if the mouse is pressed, which could be for several iterations of the draw() loop per click.
But the function only happens once per click, which sounds like exactly what you want.
void setup(){...}
void draw(){...}
void mousepressed(){
send_data(i++);
}