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.
ADVERTISEMENT