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!
Example code for multi-button checker with debouncing
Recent Entries
- Make: Holiday Gift Guide 2009: Mischief Maker's Gift Guide
- Grounding tips for mixed signal PCBs
- Virgil England's fantasy-land
- Novation Launchpad teardown
- Laptop Etch-a-Sketch via Arduino & Processing
- iPhone macro lens carousel
- New in the Maker Shed: OLLO kits
- BlueSMiRF found in credit card sniffer
- Mystery iPhone musical instrument - World's most expensive ocarina
- Stained glass d20s
Leave a comment
Subscribe to MAKE Magazine!
Subscribe today, save 42% and get web access to MAKE free. MAKE Digital Edition is available only to subscribers.
$34.95 / 1 year
(4 Quarterly Issues)




































