Oregon Institute of Technology EE333 Lab2 Conclusion "Simple Debounce" #arduino #electronics

Oregon Institute of Technology EE333 Lab2 Conclusion “Simple Debounce” #arduino #electronics

This Arduino button debounce function uses a static unsigned 16-bit integer named “state” to store the button’s state over time. The function left shifts the existing state, reads the current state of the button (HIGH or LOW), and sets the 9th bit to 1, creating a history of the last readings. The function returns true if the last eight reads were all high, indicating a debounced button press. Thank you Henry Cheung for writing the article “The Simplest Button Debounce Solution” on his E-Tinkers blog.

Leave a Reply

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

Scroll to top