#include <Bounce2.h>
#define btnRed 3
#define btnGreen 4
#define btnBlue 5
int tipka4= 2;
unsigned long timePass;
int timeDelay=150;
int ledPin = 10;
int stevec;
Bounce2::Button tipka1, tipka2, tipka3 = Bounce2::Button();
volatile byte stanje = LOW;
void setup() {
tipka2.attach(btnGreen, INPUT_PULLUP);
tipka1.attach(btnRed, INPUT_PULLUP);
tipka3.attach(btnBlue, INPUT_PULLUP);
tipka1.interval(10);
tipka2.interval(10);
tipka3.interval(10);
tipka1.setPressedState(LOW);
tipka2.setPressedState(LOW);
tipka3.setPressedState(LOW);
pinMode(ledPin, OUTPUT);
pinMode(tipka4, INPUT_PULLUP);
Serial.begin(115200);
attachInterrupt(digitalPinToInterrupt(tipka4), ISR_tipka, FALLING);
}
void loop() {
tipka1.update();
tipka2.update();
tipka3.update();
if(tipka1.pressed()){
stevec++;
Serial.println(stevec);
}
if(tipka2.pressed()){
stevec--;
Serial.println(stevec);
}
if(tipka3.pressed()){
stevec=0;
Serial.println(stevec);
}
if (stanje == HIGH && (millis() - timePass) >timeDelay){
digitalWrite(ledPin, HIGH);
stanje = LOW;
timePass=millis();
Serial.println(stanje);
}
}
void ISR_tipka(){
stanje = HIGH;
}