Alright guys , so im gonna explain about this project.This project is basically about making a security password using the arduino 4x4 keypad and also displaying it on a LCD display.Everything that is running the project will be dislpayed on the LCD display. ok lets move on to the next step.

Ok guys,so imma tell the whole function of this project . This project can be used for your Safe lock , for some restricted area or any places that needs this security pass. ok lets move on to the codes.

Ok bfore that, you guys have to declare the liquid crystal to function the lcd display or else you guys will have error on the code.Ok im just gonna tell you guys how to add the liquid crystal from the library. First go to your arduino IDE > go to sketches > click on the 'include library' > you guys can see the liquid crystal > click it.....DONE

 

#include<Keypad.h>

#include<LiquidCrystal.h>

#include<EEPROM.h>

LiquidCrystal lcd(A0,A1,A2,A3,A4,A5);

char password[4];

char pass[4],pass1[4];

int i=0;

char customKey=0;

const byte ROWS = 4; //four rows

const byte COLS = 4; //four columns

char hexaKeys[ROWS][COLS] = {

{'1','2','3','A'},

{'4','5','6','B'},

{'7','8','9','C'},

{'*','0','#','D'}

};

byte rowPins[ROWS] = {1,2,3,4}; //row pinouts of the keypad

byte colPins[COLS] = {5,6,7,8}; //column pinouts of the keypad

//initialize an instance of class NewKeypad

Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

int redLed = 10;

int greenLed = 11;

void setup()

{

lcd.begin(16,2);

pinMode(redLed, OUTPUT);

pinMode(greenLed, OUTPUT);

lcd.print(" WELCOME... ");

lcd.setCursor(0,1);

lcd.print(" Keypad Lock ");

delay(5000);

lcd.clear();

lcd.print("Enter password:");

lcd.setCursor(0,1);

for(int j=0;j<4;j++)

EEPROM.write(j, j+49);

for(int j=0;j<4;j++)

pass[j]=EEPROM.read(j);

}

void loop()

{

//digitalWrite(11, HIGH);

customKey = customKeypad.getKey();

if(customKey=='#')

change();

if (customKey)

{

password[i++]=customKey;

lcd.print(customKey);

}

if(i==4)

{

delay(200);

for(int j=0;j<4;j++)

pass[j]=EEPROM.read(j);

if(!(strncmp(password, pass,4)))

{

digitalWrite(greenLed, HIGH);

lcd.clear();

lcd.print("WELL DONE!!");

delay(1000);

lcd.clear();

lcd.setCursor(0,1);

lcd.print("YOU HAVE UNLOCKED IT,");

lcd.print(" ");

lcd.print("U ARE A GENIUS,");

for(int PositionCount=0;PositionCount<80; PositionCount++)//loop for scrolling the LCD text

{

lcd.scrollDisplayLeft();//builtin command to scroll left the text

delay(300);// delay of 150 msec

}

delay(1000);

lcd.clear();

lcd.print("Enter Passkey:");

lcd.setCursor(0,1);

i=0;

digitalWrite(greenLed, LOW);

}

else

{

digitalWrite(redLed, HIGH);

lcd.clear();

lcd.print("Access Denied...");

lcd.setCursor(0,1);

lcd.print("#.Change Passkey");

delay(10000);

lcd.clear();

lcd.print("Enter right key:");

lcd.setCursor(0,1);

i=0;

digitalWrite(redLed, LOW);

}

}

}

void change()

{

int j=0;

lcd.clear();

lcd.print("Enter Current Key");

lcd.setCursor(0,1);

while(j<4)

{

char key=customKeypad.getKey();

if(key)

{

pass1[j++]=key;

lcd.print(key);

}

key=0;

}

delay(500);

if((strncmp(pass1, pass, 4)))

{

lcd.clear();

lcd.print("Wrong Passkey...");

lcd.setCursor(0,1);

lcd.print("Enter Right Key");

delay(1000);

}

else

{

j=0;

lcd.clear();

lcd.print("Enter New Key:");

lcd.setCursor(0,1);

while(j<4)

{

char key=customKeypad.getKey();

if(key)

{

pass[j]=key;

lcd.print(key);

EEPROM.write(j,key);

j++;

}

}

lcd.print(" Done......");

delay(1000);

}

lcd.clear();

lcd.print("Enter your key:");

lcd.setCursor(0,1);

customKey=0;

}

 

If you guys have any problem regarding this project or any other , please ask me questions.I might not reply fast but i will reply as soon as possible. But im really sure that the schematics,the diagram and codes works well.

 

If you guys find this project interesting , please follow me on fritzing and not to forget my instagram. Thank you guys!!! bye