|
#include <AceButton.h> |
|
using namespace ace_button; |
|
|
|
const int BUTTON1_PIN = 18; |
|
const int BUTTON2_PIN = 19; |
|
const int BUTTON3_PIN = 5; |
|
|
|
ButtonConfig config1; |
|
ButtonConfig config2; |
|
ButtonConfig config3; |
|
|
|
AceButton button1(&config1); |
|
AceButton button2(&config2); |
|
AceButton button3(&config3); |
|
|
|
void handleEvent1(AceButton*, uint8_t, uint8_t); |
|
void handleEvent2(AceButton*, uint8_t, uint8_t); |
|
void handleEvent3(AceButton*, uint8_t, uint8_t); |
|
|
|
void setup() { |
|
Serial.begin(115200); |
|
pinMode(BUTTON1_PIN, INPUT_PULLUP); |
|
pinMode(BUTTON2_PIN, INPUT_PULLUP); |
|
pinMode(BUTTON3_PIN, INPUT_PULLUP); |
|
button1.init(BUTTON1_PIN); |
|
button2.init(BUTTON2_PIN); |
|
button3.init(BUTTON3_PIN); |
|
|
|
config1.setEventHandler(handleEvent1); |
|
config2.setEventHandler(handleEvent2); |
|
config3.setEventHandler(handleEvent3); |
|
} |
|
|
|
void loop() { |
|
button1.check(); |
|
button2.check(); |
|
button3.check(); |
|
} |
|
|
|
void handleEvent1(AceButton* button, uint8_t eventType, uint8_t buttonState) { |
|
if (eventType != AceButton::kEventReleased) |
|
return; |
|
Serial.println("Clicked1"); |
|
} |
|
|
|
void handleEvent2(AceButton* button, uint8_t eventType, uint8_t buttonState) { |
|
if (eventType != AceButton::kEventReleased) |
|
return; |
|
Serial.println("Clicked2"); |
|
} |
|
|
|
void handleEvent3(AceButton* button, uint8_t eventType, uint8_t buttonState) { |
|
if (eventType != AceButton::kEventReleased) |
|
return; |
|
Serial.println("Clicked3"); |
|
} |