Skip to content

petslane/PBtnToggle

Repository files navigation

PBtnToggle

Arduino library for handling push buttons. Supports push buttons wired to Arduino digital pin or thru PISO (parallel-in/serial out) chip like 74HC165.

Description

Arduino library for handling push buttons. Supports push buttons wired to Arduino digital pin or thru PISO (parallel-in/serial out) chip like 74HC165 with support to daisy chain multiple chips. Automatic handling of debounsing. Buttons have push event, long push event and release event.

Documentation

documentation

Demo

https://www.youtube.com/watch?v=McYEGBtuxOA

Usage

Create toggle button instance in global scope:

PBtnToggle* btn = new PBtnToggle(7, HIGH);

Register some callback functions:

void setup() {
  btn->onPress(onButtonPress);
  btn->onLongPress(onButtonLongPress);
  btn->onRelease(onButtonRelease);
}

Check() method must be called in loop(). Additionally, check() van also be called by external interrupts:

void loop() {
  btn->check();
}

Examples

Example using one button connected to Arduino digital pin: examples/one_button/one_button.ino
Example using two daisy chained PISO chips 74HC165: examples/piso_buttons/piso_buttons.ino

Daisy chain 74HC165

About

Arduino toggle button library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages