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
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);
}
}
}