#define Botao 13
#define Led 12
#define t_filtro 5
byte b_bt1;
byte b_led;
byte b_bt1_pressionado;
byte b_filtro1;
byte b_contador;
void setup() {
// put your setup code here, to run once:
pinMode(Botao, INPUT_PULLUP);
pinMode(Led, OUTPUT);
b_contador = 0;
b_led = false;
b_bt1_pressionado = false;
b_filtro1 = t_filtro;
}
void loop() {
// put your main code here, to run repeatedly:
b_bt1 = digitalRead(Botao);
if (b_bt1 == false) {
delay(10);
if (b_bt1_pressionado == false) {
if (b_filtro1 != 0) {
b_filtro1--;
} else {
b_bt1_pressionado = true;
}
}
} else {
b_filtro1 = t_filtro;
}
if (b_bt1_pressionado == true && b_filtro1 == t_filtro) {
b_contador++;
b_bt1_pressionado = false;
}
if (b_contador >= 2&& (b_led == false)) {
b_contador = 0;
b_led = true;
digitalWrite(Led, HIGH);
}
if (b_contador >= 1 && (b_led == true)) {
b_contador = 0;
b_led = false;
digitalWrite(Led, LOW);
}
}