Help with button delay on Uno 7-seg counter

OK, a few basics about debouncing:

The bounce period is generally going to be a few milliseconds, unlikely to be more than ten.

Putting "delay()" anywhere in code is just going to prevent anything happening for that period, so you really do not want to use "delay()" for any serious function - except to really delay things, which is unlikely. The use of "delay()" is referred to as "busy waiting", which means that the delay itself is being busy, but absolutely nothing else gets done. I've seen a few comparisons as to what the equivalent is in "real life" - such as sitting watching the clock to see when the cake is done.

The proper way to debounce, is to determine if the button has remained in a new state contrary to the previous accepted state for each of a number of time intervals. Typical would be ten intervals of 1 millisecond. This is done not by "busy waiting" or indeed waiting on the "clock" only when a change is detected, but polling at the rate of the time intervals, so that your "outer loop" (within the main loop) looks not at the button, but at the millis() timer and polls the button each new millisecond.

On each of these poll events, the current state of the button is read and compared to its "previous" state. If they match, the debounce count is set to the criterion (such as 10) and nothing further is done. If they do not match, the debounce counter is decremented. Until it reaches zero, nothing further is done. When it does reach zero, this indicates that number of successive polls, each successfully demonstrating the new state, so the "previous" state is set to the new state, the debounce count is again set to the criterion (ready for further polling) and the action according to the particular state change is taken.

Which action needs to be taken can be determined by noting the difference between the current and old "previous" states and this is important because this method can be used just as effectively on a byte value containing eight separate states (or in fact a longer word) as a single Boolean value, so that more than one state may be new (and of course, stable) and some may have changed in one direction and some in another.

So as well as the milliseconds counter, you need a "previous" state variable, a "current" state variable and a debounce counter.

This whole code is an element of a single pass through the main "loop" which may run many times per millisecond - or may not. If any other action in the loop delays it - such as serial output - the effective debounce time will be extended - but only by that amount and all other parts of the loop must abide by the same rules - not delaying the process other than by the actual execution of working code. Any and all time delays are effected by the same process of marking the milliseconds to start the delay and on each pass of the loop, checking how much time has passed to determine if the corresponding series of actions need to be taken.