Button sequence using LCD

Hi guys.
I’m fairly new to this but trying my best,

I have a project due soon and this is the problem statement given

''You are required to design a system where a correct code must be entered using two buttons. The code can be defined in such a way that a combination of ‘1221’ must be entered. When the correct code is displayed the LCD must display ‘ENTER’, when an incorrect code has been entered, the LCD should display ‘‘ERROR’’. When an incorrect code has been entered, the attempt must be rest by holding down button 2 for 5 seconds.

The code I have so far is attached. It uses three buttons. I’m not worried about that, but just any advice on if i’m going wrong or what can make it easier. Thanks!!

trial_run.ino (1.97 KB)

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

Have you got any pulldown resistors on the inputs or are they floating at an unknown voltage (which could be HIGH) ?