Simple AVR Button Debounce

14 Jan

I needed a simple debounce for a push button wired directly to a digital input on an ATMega.  I’m sure there are more advanced techniques but this is working well for me.

Where bit_is_clear is defined in AVR-LIBC IO.H as

and when I actually use this to detect a press I incorporate a timer to prevent another detection (double press).  The timer is started and a blocking flag cleared upon completion, which will then allow a second detection.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *