#define TASTER_PIN 2
#define LED_PIN 6
static int zaehlwert = 0 ;
void setup() {
Serial.begin(9600);
pinMode (TASTER_PIN, INPUT_PULLUP);
pinMode (LED_PIN, OUTPUT);
}
void buttonRead(){ //entprelltes Tasterauslesen
bool tasterstatus = digitalRead (TASTER_PIN);
static bool vorherigerTasterstatus = HIGH;
if (tasterstatus == LOW && vorherigerTasterstatus == HIGH) {
zaehlwert +=1 ;
Serial.print ("Zählwert: ");
Serial.println(zaehlwert);
}
vorherigerTasterstatus = tasterstatus ;
delay (50);
}
void blinkLed (int count) {
for (int i = 0; i < count; i++) {
digitalWrite(LED_PIN, HIGH); // LED an
delay(500); // 500 ms warten
digitalWrite(LED_PIN, LOW); // LED aus
delay(500);
}
}
void loop() {
buttonRead ();
blinkLed (zaehlwert);
}