// bounce circumvention
#define tipka 4
int stevec;
bool lastState = HIGH;
int zakasnitev = 100;
int zadnjiodboj = 0;
void setup() {
Serial.begin(115200);
pinMode(tipka, INPUT_PULLUP);
}
void loop() {
// pretty much the switch from python
int state = digitalRead(tipka);
if (state != lastState && (millis() - zadnjiodboj) >zakasnitev){
zadnjiodboj = millis();
lastState = state;
if(lastState == LOW){ // low so it works as soon as you click and not after you let go - use HIGH otherwise
stevec++;
Serial.println(stevec);
}
}
// - - - - - - - - - - - - - - - - - - - - - -
// only used to simulate some long program
delay(1000);
}