I tried to understand what you wanted me to change in the code and this is what it turned out as. It was a little bit confusingbut I tried my best, unfortunately there is an error at the "if (reading != lastButtonState)"
int ledState = HIGH;
int buttonState;
int lastButtonState = LOW;
uint8_t pushCount = 0;
uint32_t lastButtonPush = 0;
uint32_t doubleClickTimeout = 200;
void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, ledState);
}
void loop() {
int reading = digitalRead(buttonPin);
if (reading != lastButtonState) {
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay) {
if (reading != buttonState) {
buttonState = reading;
if (buttonState == HIGH) {
lastButtonPush = millis();
pushCount++;
}
}
}
if (pushCount && millis() - lastButtonPush > doubleClickTimeout) {
if (pushCount == 2) {
ledState = HIGH;
} else if (pushCount == 3) {
ledState = LOW;
}
pushCount = 0;
}
digitalWrite(ledPin, ledState);
lastButtonState = reading;
}