track counter

I don't get what those serial writes do, but you're doing that whenever you find the button is pressed. I think it would make more sense to do it when the button changes from unpressed to pressed. To achieve that you would need to remember the previous button state and compare it with the new state; if they differ, the button has been pressed or released. It would also be sensible to have a short delay to allow for any hardware bounce.