PROGRAMMING LED WITH A BUTTON

Hi i’m new to Arduino, and i’m trying to do a simply program, where there are some leds that when the button is HIGH, the do something, and when the button is LOW they do something else.
The thing is that leds when button is HIGH or LOW continue to do the “performance”, even if i push the button! I heard somewhere that i had to use millis() and not delay(), but I need more informations to learn how to use this function! Please help me step by step. Thanks :smiley:

const int BUTTON = 2;

void setup() {
  
 for (int pinNumber = 3; pinNumber < 13; pinNumber++) {
  pinMode(pinNumber, OUTPUT);
  pinMode(BUTTON, INPUT);
  digitalWrite(pinNumber,LOW);
  
 }

}

void loop() { 
  
 int switchState;
 switchState=digitalRead(BUTTON);
 
 
 if(switchState==HIGH){
 digitalWrite(3, HIGH);
 digitalWrite(12,HIGH);
 digitalWrite(6,LOW);
 delay(1000);
 digitalWrite(4,HIGH);
 digitalWrite(10,HIGH);
 digitalWrite(3,LOW);
 digitalWrite(12,LOW);
 delay(1000);
 digitalWrite(4,LOW);
 digitalWrite(10,LOW);
 digitalWrite(5,HIGH);
 digitalWrite(7,HIGH);
 delay(1000);
 digitalWrite(6,HIGH);
 digitalWrite(5,LOW);
 digitalWrite(7,LOW);
 delay(1000);
 digitalWrite(6,LOW);
 
 }
 
 else{
  digitalWrite(6,HIGH);
  delay(1000);
  digitalWrite(5,HIGH);
  digitalWrite(6,LOW);
  digitalWrite(7,HIGH);
  delay(1000);
  digitalWrite(7,LOW);
  digitalWrite(5,LOW);
  digitalWrite(10,HIGH);
  digitalWrite(4,HIGH);
  delay(1000);
  digitalWrite(4,LOW);
  digitalWrite(10,LOW);
  digitalWrite(12,HIGH);
  digitalWrite(3,HIGH);
  delay(1000);
  digitalWrite(6,HIGH);
  delay(1000);
  digitalWrite(5,HIGH);
  digitalWrite(6,LOW);
  digitalWrite(7,HIGH);
  delay(1000);
  digitalWrite(7,LOW);
  digitalWrite(5,LOW);
  digitalWrite(10,HIGH);
  digitalWrite(4,HIGH);
  delay(1000);
  digitalWrite(6,HIGH);
  delay(1000);
  digitalWrite(5,HIGH);
  digitalWrite(6,LOW);
  digitalWrite(7,HIGH);
  delay(1000);
  digitalWrite(6,HIGH);
  delay(1000);
  digitalWrite(6,LOW);
  digitalWrite(5,HIGH);
  digitalWrite(7,HIGH);
  delay(1000);
  digitalWrite(4,HIGH);
  digitalWrite(10,HIGH);
  digitalWrite(7,LOW);
  digitalWrite(5,LOW);
  delay(1000);
  
  
  
 }
}

First question : how is the button wired ? Second question : what do you see if you print switchState ?

The button is wired that if you push it (without keeping pressed), it is HIGH, and when you push it again is LOW.
I tried printing SwitchState but i see only a 0 before the word switchState. Every time the led program finishes in the Serial print I see a new “0switchState”…

The button is wired that if you push it (without keeping pressed), it is HIGH, and when you push it again is LOW.

That sounds weird. Can you provide a link to the button/switch that you are using and a circuit diagram ?

I tried printing SwitchState but i see only a 0 before the word switchState

If switchState is always zero then the program will never work.

UKHeliBob:
That sounds weird. Can you provide a link to the button/switch that you are using and a circuit diagram ?
If switchState is always zero then the program will never work.

Sorry if i’m not clear but i’m completely new in this forum, and Arduino in general.
The button is from Arduino Starter Kit, so I think it has to be all right with it.
I think the button works; for example when I used this button for programming one or two LED it worked, but it was a different program.

I would still like to see how the button is wired. A photograph of a hand drawing would do.