Another thing to think about is when do I start/reset the timer? When I press a button do I set that as t0 or do I check backwards to see if there has already been a button pushed? Regardless of whichever strategy you pursue, it will be useful to have a flag set while you're within the timing window. If the flag is not set, you know that you're the first (and set it).
DH12043:
for counting the presses of the button, use a lastButtonState variable so you don't count it every time through the loop.
like this:
if (lastButtonState != buttonState && buttonPin == HIGH) {
counter++;
}
That's a wee bit presumptuous at this point, don't you think? Whilst any state change is typically the catalyst for some action, that action has yet to be defined and the conditions under which the trigger occurred are as yet unknown. Granted, there are only a few options, but as long as options exist we should not be so quick as to decide a path and then force the design to conform. A button push for example, is most easily handled as active low using the input pullup resistors - no external hardware.
Maintaining an audit of the previous/existing state when testing for a new value is of course paramount and a point well mentioned to be added to OP's checklist.