Using Switch in a If if condition

Yes!
So the pin 4 button decide what state the buttonPushCounter will be in, Case 0 is the default, and then tere is state 1 to 8, and each step is turning more Led´s on....

I works now, with the Pin 4 to be a counter, and when i moved the delay into the


    if (buttonState == 0) {

      buttonPushCounter+1;  
  }

part....

Now i just need the delay to be bigger, couse otherwise the pin will trig he condition more than once!!!

  • So the "Count" is still running, if i dont put the Pin 4 to High (off) in a hurry....

the new code is below:

void loop() {

buttonState = digitalRead(BUTTON_PIN4);

if (buttonState != lastButtonState) {
  
}
    if (buttonState == LOW) {

      buttonPushCounter += 1;
      
      delay(250);  
  }



 lastButtonState = buttonPushCounter;