An Arduino library for debouncing and reading momentary contact switches such as pushbuttons. 'Long presses' of arbitrary length can be detected.
- Download Button.zip
- In the Arduino IDE, navigate to Sketch → Include Library → Add .ZIP Library...
- Browse to where Button.zip was downloaded and open it
- The library should now be installed. To use the library, navigate to Sketch → Include Library → Button
Creates a Button object.
pin
The Arduino pin number connected to the buttonmode
Choose fromINTERNAL_PULLUP
,EXTERNAL_PULLUP
, orEXTERNAL_PULLDOWN
dbtime
The debounce time for the button in milliseconds
Updates the internal state of the Button. This function polls and debounces the button.
Returns the raw, non-debounced state of the button.
Returns the debounced state of the button, indicating whether the button is pressed.
Returns the debounced state of the button, indicating whether the button is released.
Returns whether the button was pressed since the last call to update().
Returns whether the button was released since the last call to update().
Returns whether the button has been in a pressed state for at least a specified length of time.
ms
The specified length of time in milliseconds
Returns whether the button has been in a released state for at least a specified length of time.
ms
The specified length of time in milliseconds