alextaujenis / RBD_Button

Arduino Button Library - Read and debounce buttons and switches without delay or interrupts.
https://robotsbigdata.com/docs-arduino-button.html
MIT License
33 stars 9 forks source link

Multiple buttons #4

Closed rickmor10 closed 7 years ago

rickmor10 commented 7 years ago

Hi, this seems like just what I have been looking for, great work. Can you please tell me if there are any provisions for using multiple buttons, and if so how to implement this when coding.

Thanks.

alextaujenis commented 7 years ago

Multiple Button Example

#include <RBD_Timer.h>
#include <RBD_Button.h>

RBD::Button buttonA(2); // input_pullup by default
RBD::Button buttonB(3); // input_pullup by default

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

void loop() {
  if(buttonA.onPressed()) {
    Serial.println("Button A Pressed");
  }

  if(buttonA.onReleased()) {
    Serial.println("Button A Released");
  }

  if(buttonB.onPressed()) {
    Serial.println("Button B Pressed");
  }

  if(buttonB.onReleased()) {
    Serial.println("Button B Released");
  }
}