here id the code so far: No reset function yet
const int greenled = 11;
const int redled = 8;
const int b1 = 2;
const int b2 = 3;
const int b3 = 4;
const int Knapp = 5;
int pwcount;
byte combination[] = "1332";
byte userInput[4];
int buttonState0 = 0;
int buttonstate1 = 0;
int buttonstate2 = 0;
int buttonstate3 = 0;
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
pinMode(Knapp, INPUT);
digitalWrite(Knapp, LOW);
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.clear();
lcd.setCursor(0, 0);
delay (11);
lcd.print("");
delay (11);
lcd.setCursor(0, 1);
delay (11);
lcd.print("");
delay (11);
lcd.clear();
pinMode(greenled, OUTPUT);
pinMode(redled, OUTPUT);
pinMode(b1, INPUT);
pinMode(b2, INPUT);
pinMode(b3, INPUT);
Serial.begin(9600);
}
void loop(){
buttonState0 = digitalRead(Knapp);
buttonstate1 = digitalRead(b1);
buttonstate2 = digitalRead(b2);
buttonstate3 = digitalRead(b3);
if (buttonstate1 == HIGH){
userInput[pwcount] = '1';
pwcount++;
delay(300);
Serial.print('1');
}
if (buttonstate2 == HIGH){
userInput[pwcount] = '2';
pwcount++;
delay(300);
Serial.print('2');
}
if (buttonstate3 == HIGH){
userInput[pwcount] = '3';
pwcount++;
delay(300);
Serial.print('3');
}
for(byte n = 0; n <=4; n++){
if (userInput[pwcount] == combination[n] && pwcount >=4){
digitalWrite(redled, LOW);
digitalWrite(greenled, HIGH);
lcd.setCursor(0,1);
delay (11);
lcd.print("Enter");
//Serial.println("unlocked");
pwcount = 0;
}
else {
if(userInput[n] != combination[n] && pwcount >=4){
digitalWrite(greenled, LOW);
digitalWrite(redled, HIGH);
//Serial.println("Denied");
lcd.setCursor(0,1);
delay (11);
lcd.print("Error");
pwcount = 0;
n = 0;
}
}
}
}