Skip to content

Button.h

Brandon W. Kipp edited this page Feb 13, 2020 · 1 revision

This library is used to help debounce digital input signals.

To setup a new Button, you'll need to pass in two parameters:

  1. int pin, location of the input pin
  2. void (*callback)(int), a callback function that accepts the returned int value of the sensor

Example

#include "Libraries/Button.h"

Button button1;
int button1Pin = 2;

void setup() {

  button1.setup(button1Pin, [](int state) {
    if (state == 1) {
      // This means, our button was pressed
      // We should do something, like turn on a light
    }
  });

}

void loop() {
  button1.update();
}
Clone this wiki locally