int ledPin = 13;
int x = 0;
unsigned long button_time = 0;
unsigned long last_button_time = 0;
void setup() {
// put your setup code here, to run once:
pinMode(ledPin, OUTPUT);
attachInterrupt(0, increment, RISING);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(ledPin, LOW);
delay(3000);
Serial.println(x, DEC);
}
void increment() {
button_time = millis();
if (button_time - last_button_time > 250) {
x++;
digitalWrite(ledPin, HIGH);
last_button_time = button_time;
}
}