Skip to content

vkumpan/ActionButtons

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ActionButtons Arduino Library

Arduino library for handling multiple buttons with press, long press, and release detection using a simple callback mechanism.


Features

  • Supports up to 10 buttons (default, configurable via MAX_BUTTONS).
  • Detects:
    • BTN_PRESSED
    • BTN_LONG_PRESS (default 1000 ms, configurable via LONG_PRESS_MS)
    • BTN_RELEASED
  • Callback-based interface.
  • Lightweight C core with Arduino C++ wrapper.
  • Uses INPUT mode with default LOW (not pressed) and HIGH (pressed).

Installation

  1. Download or clone this repository into your Arduino libraries folder.
  2. Restart the Arduino IDE.
  3. Open File → Examples → ActionButtons to try the included demos.

Usage

Basic Example

#include <ActionButtons.h>

void buttons_activated_callback(uint8_t pin, btn_action_t action) {
  if (pin == 2 && action == BTN_PRESSED) {
    Serial.println("Button 2 PRESSED");
  }
}

uint8_t buttons[] = { 2, 3, 4 };
ActionButtons btns(buttons, 3, &buttons_activated_callback);

void setup() {
  Serial.begin(9600);
}

void loop() {
  btns.update();
  delay(100);
}

License

This project is licensed under the MIT License.

MIT License

Copyright (c) 2025 Volodymyr Kumpan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

About

Arduino library for handling multiple buttons with support for press, long press, and release events.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors