#define btnPin 2
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(btnPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(2), buttonPress, FALLING);
}
void buttonPress() {
static unsigned long lastInterrupt = 0;
if (millis() > lastInterrupt + 100) {
// Gjør det du skal her
Serial.println("Button pressed!");
lastInterrupt = millis();
}
}
void loop() {
// put your main code here, to run repeatedly:
}