GawiButtons is a lightweight Arduino library with debounced button handling. It provides a central manager for multiple buttons.
- Debounce handling with configurable timing.
- Press and hold detection.
- ButtonManager for centralized updates.
- Optional pull-up support.
- Coming soon.
- Download the .zip from GitHub.
- In the Arduino IDE -> Sketch -> Include Library -> Add .zip library or add GawiButtons to
Documents/Arduino/libraries - Include in project:
#include <GawiButtons.h>
- Create manager object to control the buttons:
ButtonManager buttonManager;- Create Button object.
addButton()dynamically creates a button within the ButtonManager object. The function returns a pointer to the new Button object.
Button* buttonBuiltIn;
buttonBuiltIn = buttonManager.addButton(9);- Manager updates all registered buttons:
buttonManager.updateAll();- Button states logic:
if (buttonBuiltIn->wasPressed()) {
Serial.println("Button was pressed.");
}
if (buttonBuiltIn->wasHeld()) {
Serial.println("Button was held.");
}- Get number of added buttons:
buttonManager.getNumButtons(); // Returns a uint8_t