help plzz Light up a led After pressing 3 time a button

i want to Light up a led After pressing 3 time a button but it Light up in the firs time please help me
here is the code

int at = 0;
void setup() {
// put your setup code here, to run once:

pinMode(8, INPUT); //BUTTON_PIN

pinMode(7, OUTPUT); //LED
}

void loop() {
if (digitalRead( 8 ) == HIGH)
{
at++;
delay(80); //wait for the button pin==LOW
}
if (at == 3) //check if the buuton has been pressed 3 time
{
digitalWrite(7, HIGH);
}
}

lp

Look at the state change detection example in the IDE (File, Examples, Digital). It does almost exactly what you are trying to do.

TNX groundfungus that's helps me a lot :slight_smile: :slight_smile: :slight_smile: