Secret knock lock, replacing piezo sensor with push button

I am doing a science fair project based on the Smart knock detecting doorknock using arduino from circuit digest which you can check out here Smart Knock Pattern Detecting Door Lock using Arduino. My problem is, i want to be able to replace a knock on the piezo sensor with the press of a push button. So instead of the arduino recognizing the pattern of knocks inputted, i would like it to recognize the pattern of button presses. If anyone could give suggestions on how to di this it would be greatly appreciated, all help is useful. here is the code if the link doesnt work
#include<EEPROM.h>
#include<Servo.h>
#define patternLength 5
#define patternInputTime 10000
#define sensitivity 80
#define margin 100
#define sw 7
#define servoPin 3
#define openGate 0
#define closeGate 180
long slot[patternLength+1];
int pattern[patternLength];
int flag=0;
int acceptFlag=0;
int knock;
Servo myServo;
void setup()
{
pinMode(sw, INPUT_PULLUP);
myServo.attach(servoPin);
myServo.write(180);
Serial.begin(9600);
}
void loop()
{
int i=0;
if(digitalRead(sw) == LOW)
{
Serial.println("Start");
delay(1000);
long stt= millis();
while(millis()<(stt+patternInputTime))
{
int temp=analogRead(A0);
if(temp>sensitivity && flag==0 && i<=patternLength)
{
delay(10);
flag=1;
slot[i++]=millis()-stt;
//Serial.println(slot[i-1] - stt);
if(i>patternLength)
break;
}
else if(temp == 0)
flag=0;
}

long stp=millis();
Serial.println("Stop");
// Serial.println(stp-stt);
for(int i=0;i<patternLength;i++)
{
knock=knock;
if(slot[i+1]-slot <500 )
_ pattern*=0;_
_
else*_
_ pattern*=1;
Serial.println(pattern);
}
if(digitalRead(sw) == 0)
{
for(int i=0;i<patternLength;i++)
EEPROM.write(i,pattern);
while(digitalRead(sw) == 0);
}
else*

* {
if(knock == knock)
{
for(int i=0;i<patternLength;i++)
{
if(pattern == EEPROM.read(i))
{
Serial.println(acceptFlag++);
}
else*

* {
Serial.println("Break");
break;
}
}
}
Serial.println(acceptFlag);
if(acceptFlag >= patternLength-1)
{
Serial.println(" Accepted");
myServo.write(openGate);*_

* delay(5000);*
* myServo.write(closeGate);*
* }*
* else*
* Serial.println("Rejected");*
* }*
* for(int i=0;i<patternLength;i++)*
* {*
_ pattern*=0;
slot=0;
}
slot=0;
acceptFlag=0;
}
}*_

Arduino hates italic code. Go back and edit your post. Help us help you.

if(knock == knock)

How can it not?

Thank you so much I kept thinking it was a problem with the code but turns out I had a resistor in a place it shouldn't be, sorry for wasting your time.

ThomasCoady76:
I kept thinking it was a problem with the code

If you have lines like this:

if(knock == knock)

... then there surely is a problem with the code.

How can a variable ever not equal itself, even without you ever explicitly making it so?

knock=knock;