const int taster = 5;
volatile long time = 0;
const long debounce = 100;
volatile int zaehler = 0;
void setup()
{
Serial.begin(9600);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(taster, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(taster), count, FALLING);
}
void loop (){
}
void updateLEDs(int value)
{
int a = value & 0x01;
int b = (value >> 1) & 0x01;
int c = (value >> 2) & 0x01;
int d = (value >> 3) & 0x01;
digitalWrite(8, a);
digitalWrite(9, b);
digitalWrite(10, c);
digitalWrite(11, d);
}
void count() {
if (millis() - time > debounce) {
zaehler++;
updateLEDs(zaehler % 16);
}
time = millis();
}