Passcode buttons

Hello! The codes below is what I want to happen. But before that, I need first to set a passcode by pressing buttons.
for example my passcode would be switches 1,4 and 3. Then it will proceed to run the below codes. If I entered incorrect password (132), then all LED’s will on then off. Then I can try another passcode. It has 6 switches, 1 for reset and 8 LED’s.
Please help me on the codes :smiley:
Thanks a lot!

int timer = 100;           
int ledPins[] = { 
  13,12,11, 10, 9, 8, 7, 6};       
int pinCount = 8;          
void setup() {
 
  for (int thisPin = 0; thisPin < pinCount; thisPin++)  {
    pinMode(ledPins[thisPin], OUTPUT);      
  }
}

void loop() {
    
    if (buttonState == HIGH) {     
    digitalWrite(ledPin, LOW);  
     for (int thisPin = 0; thisPin < pinCount; thisPin++) { 
    digitalWrite(ledPins[thisPin], HIGH);   
    delay(timer);                  
    digitalWrite(ledPins[thisPin], LOW);    

  }
  for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) { 
    digitalWrite(ledPins[thisPin], HIGH);
    delay(timer);
    digitalWrite(ledPins[thisPin], LOW);
  }
 }
}

Hello.

You could probably find pre-existing code online. A quick search on the Internet turned up these two relevant hits:

forum.arduino.cc/index.php?topic=47223.0

instructables.com/id/Passwor … h-Arduino/

-Jon

Here’s what I’ve done,

It has only 1 passcode. I’m having trouble on how to add another two passcodes. :frowning:

int timer = 100;          
int ledPins[] = { 
  13,12,11, 10, 9, 8, 7, 6};     
int pinCount = 8;           
int buttonPin = 0;
int ledPin =13;
int buttonState = 0; 
void setup() {
  pinMode(buttonPin, INPUT);   
  for (int thisPin = 0; thisPin < pinCount; thisPin++)  {
    pinMode(ledPins[thisPin], OUTPUT);      
  }
}

void loop() {
    buttonState = digitalRead(buttonPin);
    if (buttonState == HIGH) {        
    digitalWrite(ledPin, LOW);  
     for (int thisPin = 0; thisPin < pinCount; thisPin++) { 
    digitalWrite(ledPins[thisPin], HIGH);   
    delay(timer);                  
    digitalWrite(ledPins[thisPin], LOW);    

  }
  for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) { 
    digitalWrite(ledPins[thisPin], HIGH);
    delay(timer);
    digitalWrite(ledPins[thisPin], LOW);
  }
 }
}