Bounce3
A poll based debounce library with a small RAM footprint
Bounce3 Debouncing Library

Bounce3 was written to address some shortcomings of various poll based Arduino debouncing libraries–for novice programmers and advanced users alike.

The chief feature of this library is a small, unchanging RAM footprint. Each button object only consumes ten bytes of RAM, and this does not change when moving from 8-bit to 32-bit platforms.

In addition, it has a "repeat" mode, which allows the programmer to easily add functionality similar to setting a clock. When the user holds the button down for an extended period of time, the library will report multiple presses.

Example Code

While Bounce3 is quite configurable and powerful, it remains simple to use.

#include <Bounce3.h>
// Connected between D2 and GND
Bounce3 myButton(2);
void setup() {
Serial.begin(115200);
}
void loop() {
myButton.poll();
// Your code here
if(myButton.pressed()) {
Serial.println("Button pushed!");
}
}

Hardware Dependencies

For common usage, this library requires a functioning millis() call. If this call is not working, or does not exist, you can pass in the number of milliseconds since boot via the atomic functions.

This also uses the pinMode() and digitalRead() commands from the standard Arduino library.

This library was written to be platform independent, and has been tested to work on the Arduino Uno, the Feather M0, and the ESP32.

Author

Tim Kuester

License

MIT Licensed, 2019