A library for using a simple mechanical push (momentary) button as a momentary button, a latching button, a counter, an enumerator, and more. The library allows a mechanical momentary button to be used as a virtual button with different functionality. The library implements the behavior of a momentary button, a latching button, a counter, an enumerator, and more. It also makes it very easy to develop buttons with your own custom behavior. The Bounce2 library is used to add debouncing functionality.
Note that because some input devices like optical sensors or limit switches are functionally equivilent to tactile buttons, they can also be used with this library.
This library contains two categories of button types. The first category is two state buttons; these are either on or off. The second category provides incrementing buttons that can perform different types of counting. These two categories of buttons are described here. See "Software Design" below for information about how the source code implements these behaviors.
These are binary state buttons and can only be on or off.
This is standard push (momentary) button. It returns true when the button is pressed (held down) and false when it is not.
Turns a push button (momentary button) into a toggle button (latching button). Pressing the button alternates between on (true) and off (false). This is a virtual latching switch controled by a mechanical momentary button.
This button class captures each individual button press as discrete events. It does not matter how long the button is pressed down or released. Only the transition between pressed and released is captured. It can capture either the press event or the release event.
Always returns that the button is on. Useful if you want to temporarily disable user input.
Always returns that the button is off. Useful if you want to temporarily disable user input.
These buttons provide different types of counting behavior.
Turns a push button (momentary button) into a counter. The counter is incremented each time the button is pushed. The counter continues to increment until it is reset either by the user (with a long press) or programically.
Turns a push button (momentary button) into a button used to cycle through states (for example, an enumeration). Pressing the button causes the value to increment. Once the maximum value is reached, the value automatically resets to the initial value. The value can also be reset to the initial value programmically or by the user (with a long press).
Visit the Wiki to learn how the software is designed.
https://github.com/lendres/ButtonSuite-Arduino
The purpose of Version 2 was to greatly simplify the interface as well as the internal structure of the software. Some of the more esoteric functionality was removed and some functionality was separated into different classes. This meant backwards compatibility could not be maintained, however, the benefit is a much cleaner and easier to understand library.
This library requires the following librarys to run:
- Bounce2 - Debouncer for Arduino
For information on installing Arduino libaries, see: Arduino Libraries
We use SemVer for versioning.
- Lance A. Endres - lendres
This project is licensed under the MIT License - see the LICENSE file for details.