#define BOT_PIN A1
struct button{
char* name;
bool currentState;
bool lastState;
};
void setup() {
Serial.begin(115200);
pinMode(BOT_PIN, INPUT_PULLUP);
}
unsigned long tempoPressionado;
unsigned long tempoAtual;
int val;
void loop() {
delay(100);
bool btn = digitalRead(BOT_PIN);
static bool lastBtn;
if(btn){
if(lastBtn) {
val++;
Serial.println(val);
lastBtn = false;
}
tempoAtual = millis();
}else{
if(millis() - tempoAtual > 3000){
Serial.println("Long");
tempoAtual = millis();
lastBtn = true;
btn = false;
}
else if(!lastBtn) {
Serial.println("Down");
lastBtn = true;
}
}
}