Step 1 go to the sketch tab and hover over include library and click manage libraries and search Keypad and it is the 3rd one down its also by Mark Stanley, Alexander Brevig Version 3.1.0
This is all of my code.
// Librarys
#include <SPI.h>
//Where it is messing up
#include <Keypad.h>
#include <MFRC522.h>
#include <LiquidCrystal.h>
// Variables
boolean locked = true;
boolean active = false;
boolean Q1 = false;
boolean typing1 = false;
boolean typing2 = false;
boolean keycard = false;
String stillText0 = "Press 1 to Scan";
String stillText1 = " Key";
String stillText2 = "Press 2 to Enter";
String stillText3 = "Code";
String unlockedText = "Unlocked For ";
String currentPressed = "";
String a1 = "1";
String a2 = "2";
String Clear = "";
String Enter = "#";
String attempt = "";
String masterPass = "2170";
String pass = "1454";
char customKey;
unsigned long lastMillStart = 0;
unsigned long lastMillQ1 = 0;
unsigned long lastActive = 0;
int intervalOne = 500;
int intervalTwo = 3000;
int intervalThree = 30000;
int choice1;
int textSwitch = -1;
int uses = 2;
int unlockedFor;
LiquidCrystal lcd(2, 3, 4, 5, 6, 7); // Creates an LC object. Parameters: (rs, enable, d4, d5, d6, d7)
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'', '0', '#', 'D'}
};
byte rowPins[ROWS] = {39, 40, 41, 42}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {43, 44, 45, 46}; //connect to the column pinouts of the keypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
#define RST_PIN 10
#define SS_PIN 53
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
void setup() {
pinMode(9, OUTPUT);
lcd.begin(16, 2);
lcd.clear();
Serial.begin(9600);
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
}
void loop() {
customKey = customKeypad.getKey();
if(active == true && typing1 == true){
currentPressed = customKey;
Serial.println(currentPressed);
}
if (millis() > lastActive + intervalThree && active == true) {
locked = true;
Q1 = false;
attempt = "";
choice1 = 0;
keycard = false;
typing1 = false;
typing2 = false;
active = false;
lastActive = millis();
lcd.noBlink();
lcd.clear();
}
if (millis() >= lastMillStart + intervalOne && locked == true && active == false) {
lcd.setCursor(0,0);
lcd.print(" Press Any Key to Begin");
lcd.scrollDisplayLeft();
lastMillStart = millis();
}
if (customKey && locked == true && active == false) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(stillText0);
lcd.setCursor(6, 1);
lcd.print(stillText1);
lastMillQ1 = millis();
lastActive = millis();
typing1 = true;
active = true;
}
if (millis() >= lastMillQ1 + intervalTwo && locked == true && active == true) {
lcd.clear();
textSwitch = textSwitch * -1;
lastMillQ1 = millis();
}
if (textSwitch == -1 && locked == true && active == true && Q1 == false) {
lcd.setCursor(0, 0);
lcd.print(stillText0);
lcd.setCursor(6, 1);
lcd.print(stillText1);
} else if (textSwitch == 1 && locked == true && active == true && Q1 == false) {
lcd.setCursor(0, 0);
lcd.print(stillText2);
lcd.setCursor(6, 1);
lcd.print(stillText3);
}
if (locked == true && active == true && Q1 == false && currentPressed == a1 && choice1 == 0) {
lcd.clear();
choice1 = 1;
lastActive = millis();
Q1 = true;
} else if (locked == true && active == true && Q1 == false && currentPressed == a2 && choice1 == 0) {
lcd.clear();
choice1 = 2;
lastActive = millis();
Q1 = true;
}
if (choice1 == 1 && locked == true && active == true && Q1 == true) {
lcd.setCursor(0, 0);
lcd.print("Scan Keycard");
lastActive = millis();
rfidScan();
} else if (choice1 == 2 && locked == true && active == true && Q1 == true) {
lastActive = millis();
typing2 = true;
passDisplay();
}
if(typing2 = true && customKey != Enter && customKey != Clear && customKey){
attempt = attempt + currentPressed;
lastActive = millis();
}
if(typing2 = true && currentPressed == Enter){
passCheck();
lastActive = millis();
lcd.clear();
}
if(typing2 = true && currentPressed == Clear){
attempt = "";
lcd.clear();
lastActive = millis();
}
}
void rfidScan() {
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
lastActive = millis();
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
lastActive = millis();
return;
}
if (mfrc522.uid.uidByte[0] == 0xb6 &&
mfrc522.uid.uidByte[1] == 0xf1 &&
mfrc522.uid.uidByte[2] == 0x68 &&
mfrc522.uid.uidByte[3] == 0xac) {
lastActive = millis();
keycard = true;
lcd.clear();
keyunlocked();
}
}
void keyunlocked() {
if(keycard == true && locked == true && choice1 == 1){
locked = false;
digitalWrite(9,HIGH);
for (int i=5; i>-1; i--) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(unlockedText + i);
//lcd.setCursor(0, 1);
//lcd.print(i);
delay(1000);
unlockedFor++;
}
digitalWrite(9,LOW);
locked = true;
Q1 = false;
attempt = "";
choice1 = 0;
keycard = false;
typing1 = false;
active = false;
lcd.clear();
}
}
void passDisplay(){
if(typing2 = true){
lcd.setCursor(0, 0);
lcd.print("Enter Code");
lcd.setCursor(0, 1);
lcd.blink();
lcd.print(attempt);
}
}
void passCheck() {
if (locked == true && attempt == masterPass && attempt.length() == 4) {
locked = false;
lcd.clear();
for (int i=5; i>-1; i--) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(unlockedText + i);
//lcd.setCursor(0, 1);
//lcd.print(i);
delay(1000);
unlockedFor++;
}
}
if (locked == true && attempt == pass && attempt.length() == 4) {
locked = false;
digitalWrite(9,HIGH);
lcd.clear();
for (int i=5; i>-1; i--) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(unlockedText + i);
//lcd.setCursor(0, 1);
//lcd.print(i);
delay(1000);
unlockedFor++;
}
digitalWrite(9,LOW);
}
if (unlockedFor > 5 && locked == false) {
locked = true;
unlockedFor = 0;
lcd.clear();
attempt = "";
digitalWrite(9,LOW);
}
}