Two Button Passcode Lock

I am relatively new to arduino and having a few problems on one of my projects. I am attempting to make a combination lock, using two buttons, that activate a servomotor when the correct sequence is pressed. I have it sort of figured out - the correct combination is supposed to be "1221" (in reference to the buttons). However, any sequence beginning with a 1 is passing as correct. My code is attached in the file below. Any help would be greatly appreciated. For those of you too sketched out to open the file, here is the code below. Sorry if the formatting is not great.

// Which pins things are attached to

#include <Servo.h>
Servo myServo;

const int b1 = 3;
const int b2 = 4;
const int b3 = 7;
const int correctLed = 5;
const int incorrectLed = 6;

// button states when they are pressed

int bs1 = 0;
int bs2 = 0;
int bs3 = 0;

int pwcount = 0;
int combination[4] = {1, 2, 2, 1};
int userInput[4];

void setup() {
myServo.attach(2);
pinMode(b1, INPUT);
pinMode(b2, INPUT);
pinMode(b3, INPUT);
pinMode(correctLed, OUTPUT);
pinMode(incorrectLed, OUTPUT);

Serial.begin(9600);
}

void loop() {

digitalWrite(incorrectLed, LOW);
digitalWrite(correctLed, LOW);
static int pushCounter = 0;
bs1 = digitalRead(b1);
bs2 = digitalRead(b2);

if (bs1 == HIGH){
userInput[pwcount] = 1;
pwcount++;
delay(300);
Serial.print('1');
}
if (bs2 == HIGH){
userInput[pwcount] = 2;
pwcount++;
delay(300);
Serial.print('2');
}

int n = 0;

for(n = 0; n < 4; n++){

if (userInput[n] == combination[n] && pwcount == 4){
digitalWrite(correctLed, HIGH);
Serial.println("unlocked");
myServo.write(179);
delay(3000);
pwcount = 0;

}
else {
if(userInput[n] != combination[n] && pwcount == 4){
digitalWrite(incorrectLed, HIGH);
Serial.println("Denied");
delay(2000);
pwcount = 0;
n = 0;
}

bs3 = digitalRead(b3);

if(bs3 == HIGH){
myServo.write(1);
}

}
}
}

lock_sketch.ino (1.53 KB)

connordgrant:
I am relatively new to arduino and having a few problems on one of my projects. I am attempting to make a combination lock, using two buttons, that activate a servomotor when the correct sequence is pressed.

Reading the buttons is a big mess in your code.

"Pressing a button" is in fact an action: The buttons changes from "released state" to "pressed state".

It depends on the circuit, whether a button is rleased state is HIGH and in pressed state LOW, or maybe the other way round.
But anyway: You will have to do a "state change detection" in your code to detect a button press.

What your code is doing: The code asks whether the current state is HIGH.
What your code is NOT doing: Asking whether the state changes from LOW to HIGH.

So maybe the user presses the button once and holds it down foreever without releasing.
Your code will then detect button presses endlessly.

The user presses the button and holds it down.
But your code detects one pressed button and the next pressed button and the next pressed button forever and forever, without any user action happening.
That's wrong button code.

You will have to do correct button logic handling and have to detect a "state change". Maybe your button circuit is using a pull-down resistor and switches agains 5V, then you will have to detect when the state changes(!) to HIGH after being LOW before! That's the action of "pressing the button". If the button then reads HIGH all the time afterwards, nothing is happening, the user just holds the button down in pressed state, but he is not doing any action.