/*
OneButon - several functions
https://forum.arduino.cc/t/taste-fur-verschiedene-funktionen-verwenden/1115508
2023-04-15 by noiasca
to be deleted: 2023-06
code in forum
*/
#include "OneButton.h" //we need the OneButton library
const uint8_t buttonPin = A0;
OneButton button(buttonPin, true, true);
void doA(){
Serial.println(F("doA"));
}
void doB() {
static uint8_t counter = 0;
counter++;
if (counter > 5) counter = 0;
Serial.println(counter);
}
void setup() {
Serial.begin(115200);
button.attachClick(doA);
button.attachLongPressStart(doB);
}
void loop() {
button.tick();
}