Skip to content

1. Using the Library

Caio Frota edited this page Mar 5, 2021 · 1 revision

alt text

CF Push Button for Arduino

Using the Library

  • Schematic SCHEME

  • Include in your sketch.

#include <CFPushButton.h>
  • Initialize library.
#define PIN_PUSH_BUTTON D2
CFPushButton pushButton(PIN_PUSH_BUTTON);
  • Create a function for OnPressCallback
void onPressCallback() {
    // Do something...
}
  • Also in the setup function add
void setup() {
    // ... YOUR CODE ...
    // Define callback.
    pushButton..setOnPressCallback(onPressCallback);
    
    // Start push button.
    pushButton.begin();
    // ... YOUR CODE ...
}
  • And in your loop function
void loop() {
    // ... YOUR CODE ...
    pushButton.loop();
    // ... YOUR CODE ...
}
Clone this wiki locally