Example code for multi-button checker with debouncing

Arduino

6Button
Ladyada writes

If you have a lot of button inputs for a project, keeping track of them (whether they’re pressed, just pressed or just released) and debouncing can get a bit hairy. here is some sample code that will keep track of as many buttons as you’d like. The example shows 6. To change the pins or number of buttons, just put them in the array called “buttons” and the rest of the code will automatically adjust. (The code is in Arduino-ese but its pretty much just straight up C) Enjoy!

What will the next generation of Make: look like? We’re inviting you to shape the future by investing in Make:. By becoming an investor, you help decide what’s next. The future of Make: is in your hands. Learn More.

current: @adafruit - previous: MAKE, popular science, hackaday, engadget, fallon, braincraft ... howtoons, 2600...

View more articles by Phillip Torrone
Discuss this article with the rest of the community on our Discord server!

ADVERTISEMENT

Escape to an island of imagination + innovation as Maker Faire Bay Area returns for its 16th iteration!

Prices Increase in....

Days
Hours
Minutes
Seconds
FEEDBACK