Press & hold functionality with Arduino

Arduino Technology


From the MAKE Flickr pool

Flickr member jmsaltzman coded some extra functionality into a basic momentary pushbutton –

To get more functionality out of a single button and to add a “hidden” mode, I extended button debouncing logic to allow for click as well as press+hold. The green LED toggles when the button is clicked, and the red LED toggles on press and hold. In this example, the hold time is 2 sec.

Of course this technique comes in very handy when your project is running low on available pins. Arduino compatible code is available in the comments of his blog entry.

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.

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