IOT

How to design Password-Based Door Lock Security System Using Arduino & Keypad

We are living in a technology-based society where we have lots of innovative ideas day by day. These new innovations in electronics-based projects, strive constantly to share and gather insight on the latest trends in the industrial IoT landscape.

As we all know that the real-time application has been increasing day by day, and the smart connection also had increased. Here we are going to design a Password-Based Security System Using Arduino & Keypad

Proposed System

We’ll learn how to construct a Password-Based Security System with Arduino and a Keypad in this project. As the number of thefts rises every day, security is becoming a serious worry. As a result, a digital code lock may easily safeguard your home or locker. It will only unlock your door if you input the correct password.

This project’s circuit is fairly simple, consisting of an Arduino, a keypad module, a buzzer, a servo motor, and an LCD. The entire procedure, including accepting a password from the keypad module, comparing passwords, triggering a buzzer, spinning a servo motor, and communicating status to the LCD display, is controlled by Arduino. The password is entered via the keypad. The buzzer serves as a signal. A servo motor opens the gate while it rotates, and an LCD is utilized to display status or messages.

Components Required:

  • Arduino UNO R3 Development Board
  • 4X3 Keypad
  • JHD162A 16×2 LCD Display
  • Potentiometer
  • SG90 Servo Motor
  • 5V Active Buzzer
  • Connecting Wires
  • Breadboard

Circuit Diagram & Connections

The Password Based Door Lock Security System’s circuit or schematic is pretty simple. The Fritzing Software can be used to create the schematic.

Password Based Door Lock Security System Using Arduino & Keypad

First and foremost, we’ll connect to the 4×3 Keypad. Digital pins D1 to D7 are used to connect the keypad to the Arduino. Connect the keypad’s seven pins to Arduino’s analog pins D1 to D7.

To connect the servo motor to the Arduino, utilize the digital pin D9 to output the servo motor’s PWM pin. Connect the buzzer’s positive wire to Arduino’s pin D10, and the buzzer’s negative wire to the ground.

Now we will connect the 16×2 LCD to the Arduino.

1. Connect pins 1,3,5,16 of LCD to the GND.

2. Connect pin 2,15 of LCD to the VCC (5V).

3. Connect pin 4 of LCD to pin A0 of Arduino.

3. Connect pin 6 of LCD to pin A1 of Arduino.

3. Connect pin 11 of LCD to pin A2 of Arduino.

3. Connect pin 12 of LCD to pin A3 of Arduino.

3. Connect pin 13 of LCD to pin A4 of Arduino.

3. Connect pin 14 of LCD to pin A5 of Arduino.

Another version of the Schematic created with the EasyEDA program is shown below. The Arduino Nano Board has taken the place of the Arduino UNO Board.

Schematic Password Door Lock Security

Schematics, PCB & Gerber File + PCB Ordering Online

If you don’t want to put the circuit together on a breadboard and instead want a PCB for your project, here is the PCB for you. EasyEDA online Circuit Schematics & PCB Design tool was used to create the project’s PCB Board. The PCB’s front and back sides are shown below.

Fig: PCB Top ViewFig: PCB Bottom View

Download Gerber File: Password Security System Project

Now you can visit the PCBgogo official website by clicking here: https://www.pcbgogo.com/. So you will be directed to the PCBgogo website. Register now to get 50$ coupon for new users

You can now upload the Gerber File to the Website and place an order. The PCB quality are of top class and brilliant. That is why most people trust PCBgogo for PCB & PCBA Services.

Working on Password Based Door Lock Security System

In this project, we’ve set Arduino’s default password to “4567.” It’s possible to change it by coding. When we enter a password, the Arduino compares it to the password it has stored. If it’s right, it’ll display ‘Access Granted, Welcome’ before rotating the servo motor to 180 degrees when the door opens. It will then give you 5 seconds to enter through the door. The door will automatically lock when 5 seconds have passed.

If the password is incorrect, the message ‘Code Incorrect, Go Away’ will appear. When any key is pressed, the buzzer will sound once.

Password Based Door Lock Security System Using Arduino & Keypad

Source Code/Program

The code for a Password-Based Door Lock Security System using Arduino and Keypad may be found below. Using the Arduino IDE, you can simply copy and paste the code. After that, just compile it and upload it to the ATmega328 microcontroller.

Below is a link to the Keypad.h library.

Download Keypad.h library

#include <Keypad.h>
#include <LiquidCrystal.h>
#include <Servo.h>
Servo myservo;
int pos=0; // LCD Connections
LiquidCrystal lcd(A0,A1,A2,A3,A4,A5);
const byte rows=4;
const byte cols=3;
 
char key[rows][cols]={
{‘1′,’2′,’3’},
{‘4′,’5′,’6’},
{‘7′,’8′,’9’},
{‘*’,’0′,’#’}
};
byte rowPins[rows]={1,2,3,4};
byte colPins[cols]={5,6,7};
Keypad keypad= Keypad(makeKeymap(key),rowPins,colPins,rows,cols);
char* password=”4567″;
int currentposition=0;
int redled=10;
int greenled=11;
int buzz=8;
int invalidcount=12;
 
 
 
void setup()
{
 
displayscreen();
Serial.begin(9600);
pinMode(redled, OUTPUT);
pinMode(greenled, OUTPUT);
pinMode(buzz, OUTPUT);
myservo.attach(9); //SERVO ATTACHED//
 
lcd.begin(16,2);
 
}
 
void loop()
{
if( currentposition==0)
{
displayscreen();
 
}
int l ;
char code=keypad.getKey();
if(code!=NO_KEY)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“PASSWORD:”);
lcd.setCursor(7,1);
lcd.print(” “);
lcd.setCursor(7,1);
for(l=0;l<=currentposition;++l)
{
 
lcd.print(“*”);
keypress();
}
 
if (code==password[currentposition])
{
++currentposition;
if(currentposition==4)
{
 
unlockdoor();
currentposition=0;
 
}
 
}
 
else
{
++invalidcount;
incorrect();
currentposition=0;
 
}
if(invalidcount==5)
{
 
++invalidcount;
torture1();
 
}
if(invalidcount==8)
{
torture2();
}
 
}
// LOOP ENDS!!!//
}
 
//********OPEN THE DOOR FUNCTION!!!!***********//
 
void unlockdoor()
{
delay(900);
 
lcd.setCursor(0,0);
lcd.println(” “);
lcd.setCursor(1,0);
lcd.print(“Access Granted”);
lcd.setCursor(4,1);
lcd.println(“WELCOME!!”);
lcd.setCursor(15,1);
lcd.println(” “);
lcd.setCursor(16,1);
lcd.println(” “);
lcd.setCursor(14,1);
lcd.println(” “);
lcd.setCursor(13,1);
lcd.println(” “);
unlockbuzz();
 
for(pos = 180; pos>=0; pos-=5) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(5); // waits 15ms for the servo to reach the position
}
delay(2000);
 
 
 
delay(1000);
counterbeep();
 
delay(1000);
 
for(pos = 0; pos <= 180; pos +=5) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15);
 
 
currentposition=0;
 
lcd.clear();
displayscreen();
 
}
}
 
//************WRONG CODE FUNCTION********//
 
void incorrect()
{
delay(500);
lcd.clear();
lcd.setCursor(1,0);
lcd.print(“CODE”);
lcd.setCursor(6,0);
lcd.print(“INCORRECT”);
lcd.setCursor(15,1);
lcd.println(” “);
lcd.setCursor(4,1);
lcd.println(“GET AWAY!!!”);
 
lcd.setCursor(13,1);
lcd.println(” “);
Serial.println(“CODE INCORRECT YOU ARE UNAUTHORIZED”);
digitalWrite(redled, HIGH);
digitalWrite(buzz, HIGH);
delay(3000);
lcd.clear();
digitalWrite(redled, LOW);
digitalWrite(buzz,LOW);
displayscreen();
}
//************** CLEAR THE SCREEN!!!*************//
void clearscreen()
{
lcd.setCursor(0,0);
lcd.println(” “);
lcd.setCursor(0,1);
lcd.println(” “);
lcd.setCursor(0,2);
lcd.println(” “);
lcd.setCursor(0,3);
lcd.println(” “);
}
//**************KEYPRESS********************//
void keypress()
{
 
 
 
digitalWrite(buzz, HIGH);
delay(50);
digitalWrite(buzz, LOW);
}
//********DISPALAY FUNCTION!!!*************//
void displayscreen()
{
 
lcd.setCursor(0,0);
lcd.println(“*ENTER THE CODE*”);
lcd.setCursor(1 ,1);
 
lcd.println(“TO _/_ (OPEN)!!”);
}
//*************** ARM SERVO***********//
void armservo()
{
 
for (pos=180;pos<=180;pos+=50)
{
myservo.write(pos);
delay(5);
}
delay(5000);
 
for(pos=180;pos>=0;pos-=50)
{
myservo.write(pos);
}
 
}
//**********UNLOCK BUZZ*************//
void unlockbuzz()
{
 
digitalWrite(buzz, HIGH);
delay(80);
digitalWrite(buzz, LOW);
delay(80);
digitalWrite(buzz, HIGH);
delay(80);
digitalWrite(buzz, LOW);
delay(200);
digitalWrite(buzz, HIGH);
delay(80);
digitalWrite(buzz, LOW);
delay(80);
digitalWrite(buzz, HIGH);
delay(80);
digitalWrite(buzz, LOW);
delay(80);
}
 
//**********COUNTER BEEP**********//
void counterbeep()
{
delay(1200);
 
 
lcd.clear();
digitalWrite(buzz, HIGH);
 
lcd.setCursor(2,15);
lcd.println(” “);
lcd.setCursor(2,14);
lcd.println(” “);
lcd.setCursor(2,0);
delay(200);
lcd.println(“GET IN WITHIN:::”);
 
lcd.setCursor(4,1);
lcd.print(“5”);
delay(200);
lcd.clear();
lcd.setCursor(2,0);
lcd.println(“GET IN WITHIN:”);
digitalWrite(buzz,LOW);
delay(1000);
//2
digitalWrite(buzz, HIGH);
lcd.setCursor(2,0);
lcd.println(“GET IN WITHIN:”);
lcd.setCursor(4,1); //2
lcd.print(“4”);
delay(100);
lcd.clear();
lcd.setCursor(2,0);
lcd.println(“GET IN WITHIN:”);
digitalWrite(buzz,LOW);
delay(1000);
//3
digitalWrite(buzz, HIGH);
lcd.setCursor(2,0);
lcd.println(“GET IN WITHIN:”);
lcd.setCursor(4,1); //3
lcd.print(“3”);
delay(100);
lcd.clear();
lcd.setCursor(2,0);
lcd.println(“GET IN WITHIN:”);
digitalWrite(buzz,LOW);
delay(1000);
//4
digitalWrite(buzz, HIGH);
lcd.setCursor(2,0);
lcd.println(“GET IN WITHIN:”);
lcd.setCursor(4,1); //4
lcd.print(“2”);
delay(100);
lcd.clear();
lcd.setCursor(2,0);
lcd.println(“GET IN WITHIN:”);
digitalWrite(buzz,LOW);
delay(1000);
//
digitalWrite(buzz, HIGH);
lcd.setCursor(4,1);
lcd.print(“1”);
delay(100);
lcd.clear();
lcd.setCursor(2,0);
lcd.println(“GET IN WITHIN::”);
digitalWrite(buzz,LOW);
delay(1000);
//5
digitalWrite(buzz, HIGH);
delay(40);
digitalWrite(buzz,LOW);
delay(40);
digitalWrite(buzz, HIGH);
delay(40);
digitalWrite(buzz,LOW);
delay(40);
digitalWrite(buzz, HIGH);
delay(40);
digitalWrite(buzz,LOW);
delay(40);
digitalWrite(buzz, HIGH);
delay(40);
digitalWrite(buzz,LOW);
lcd.clear();
lcd.setCursor(2,0);
lcd.print(“RE-LOCKING”);
delay(500);
lcd.setCursor(12,0);
lcd.print(“.”);
delay(500);
lcd.setCursor(13,0);
lcd.print(“.”);
delay(500);
lcd.setCursor(14,0);
lcd.print(“.”);
delay(400);
lcd.clear();
lcd.setCursor(4,0);
lcd.print(“LOCKED!”);
delay(440);
}
//*********TORTURE1***********//
void torture1()
{
delay(1000);
lcd.clear();
lcd.setCursor(2,0);
lcd.print(“WAIT FOR “);
lcd.setCursor(5,1);
lcd.print(“15 SECONDS”);
digitalWrite(buzz, HIGH);
delay(15000);
digitalWrite(buzz, LOW);
lcd.clear();
lcd.setCursor(2,0);
lcd.print(“LOL..”);
lcd.setCursor(1,1);
lcd.print(” HOW WAS THAT??”);
delay(3500);
lcd.clear();
 
}
//*****TORTURE2*****//
void torture2()
{
delay(1000);
lcd.setCursor(1,0);
lcd.print(” “);
lcd.setCursor(2,0);
lcd.print(“EAR DRUMS ARE”);
lcd.setCursor(0,1);
lcd.print(” PRECIOUS!! “);
delay(1500);
lcd.clear();
lcd.setCursor(1,0);
lcd.print(” WAIT FOR”);
lcd.setCursor(4,1);
lcd.print(” 1 MINUTE”);
digitalWrite(buzz, HIGH);
delay(55000);
counterbeep();
lcd.clear();
digitalWrite(buzz, LOW);
lcd.setCursor(2,0);
lcd.print(“WANT ME TO”);
lcd.setCursor(1,1);
lcd.print(“REDICULE MORE??”);
delay(2500);
lcd.clear();
lcd.setCursor(2,0);
lcd.print(“Ha Ha Ha Ha”);
delay(1700);
lcd.clear();
}

Conclusion

I hope all of you understand how to design Password Based Door Lock Security System Using Arduino & Keypad. We MATHA ELECTRONICS will be back soon with more informative blogs.

Leave a Reply

Your email address will not be published.