I wrote this for toggle switches. It first looks for a change of state. If seen, it counts loops to be constantly in that state, any reversal reloads counter. Exit is by loop countout: consistent state change OR too many reloads. In effect, it soft delays out the bounce. The loop counts set debounce delay and excessive reload countout. My std rules: free to use, But put "uMax/Sarge" associated with it somewhere. TNX <<<)))
Code:
dbict equ $10 ;debounce Inactive count...