Password Based Door Lock System Using 8051 Microcontroller

A password-based door lock system using an 8051 microcontroller is a project where you can secure your doors with a password. Traditional lock systems which are using mechanical locks are replaced by modern technologies. These techniques are electrical and highly intelligent. These systems are also very efficient than older locks. We can use the door unlocking system as an automated room appliance. Like we open the door and the light and fan of the room turn on.

In this project, we going to build a password-based door lock system using an AT89C51 microcontroller. This project also provides the control to actuating the load. This system is very easy to use like only with a keypad you can operate it.

In this present day, this system is used to protect secure areas. Where those people can only enter who have passwords or permission to enter. After anyone enters the room the doors locked again. When any other arrives, the system asks for a password. If this person enters the wrong password the doors remain closed.

Must Read Celsius Scale Digital Thermometer Using AT89C51 Microcontroller

Principle Behind Password Based Door Lock System

This project is based on an 8051 microcontroller. The 4×4 matrix keypad is used here to enter the password. The system compares this password with the predefined password. 

When two passwords are matched, the system opens the door by rotating the motor. It also displays the status of the doot in the LCD. If the password does not match the door remains closed and it displays “PWD is wrong” on LCD.

Project

Password Based Door Lock System Algorithm

  • At first, we take PORT1 to LCD data pins and P3.0 and P3.2 to control pins (Rs and E). Then declare PORT2 to the keypad. We connect the motor driver to P0.0 and P0.1.
  • Then the LCD displays the “enter the password” message.
  • After entering the password by the user, it starts to read the five-digit password.
  • The microcontroller compares the entered password and predefined password.
  • If the password is matched, then make P0.0 HIGH and P0.1 LOW. So the door opens. During this, the LCD displays “Door opening”.
  • After 10 seconds the microcontroller makes P0.0 LOW and P0.1 HIGH. So the door again locked.
  • If the entered password does not match, the LCD displays “Wrong Password”. So the door remains locked.
  • After a delay, it displays again to enter the password.

Circuit Diagram

Password Based Door Lock System Circuit Diagram

Components Required

Hardware Requirements

  • 8051 Microcontroller (AT89C51)
  • 8051 Development Board
  • Programmer (8051)
  • 4×4 Matrix Keypad
  • 16×2 LCD
  • 7805 Regulator IC
  • 100uF/25V Capacitor
  • 0.1uF Ceramic Capacitor
  • L293D Motor Driver IC
  • DC Motor
  • 10KΩ Potentiometer
  • Connecting Wires
  • 9V-12V Power Supply

Software Requirements

  • Keil µVision IDE
  • Willar Programmer

Additional Components

If 8051 Development Board is not used, then the following components are needed.

  • 11.0592 MHz Quartz Crystal
  • 2 x 33pF Ceramic Capacitors
  • 2 x 10 KΩ Resistor (1/4 Watt)
  • 10 µF Capacitor (Polarized)
  • Push Button
  • 2 x 1 KΩ Resistors (for pull up)

8051 Microcontroller Connection Section

To build the password-based door lock system using the 8051 microcontroller circuit, we have five main components. Those are an AT89C52 Microcontroller, an L293D Motor driver, a DC motor, a 4×4 Matrix keypad, and last thing is a 16×2 LCD. In this project, we use the AT89C52 Microcontroller as an 8 – bit controller. This controller work on +5V DC. We use 7805 IC to provide this 5V to the microcontroller. You can use a 9V/12V battery or 12V,1A adapter as a power supply of this circuit.

Reset Section

The reset pin of the microcontroller is kept active until the specified range of the power supply is changed. In other words to ensure the voltage does not fall below 1.2V. The minimum oscillation must be maintained and this is the second criteria to remain the reset pin activated. The reset pulls width is 100ms. For these two criteria, we select a 10K resistor and 10uF electrolytic capacitor to maintain RC >= 100ms.

Oscillator Section

In this project, we use an 11.0592 MHz crystal oscillator to provide the external clock signal to the microcontroller. For smooth operation, we connect two ceramic capacitors of 33pF. The crystal connects between pin 18 and 19 of the microcontroller.

Connecting LCD, Keypad, And Motor Driver IC

After connecting the crystal, we take a 10K potentiometer and connect it with the LCD’s contrast pin ( no. 3). RS, RW, and E of the LCD are connected to P3.0, GND, and P3.2 pins respectively. The data lines of the LCD are connected to P1.

Pins P2.0 and P2.3 are connected to the four ROW pins of the keypad. The COLUMN pins are connected to pins P2.4 and P2.7. The input pins ( 1A and 2A) of the L293D motor driver are connected to P0.0 and P0.1. We connect the motor between output pins (1Y and 2Y) of L293D.

Compilation of Microcontroller Code

Hence we complete connecting all the parts of this circuit. Now we have to compile with the code. Keli uVision software is used here to write the program in C language.

Some basic steps to be followed like creating a new project and select the required microcontroller. After writing the code we save the file with an extension of c. Then add it to the source file under the target folder. Now press F7 to compile the code.

After compiling the code you can see a hex file is created. Then we use Easy EDA software to draw the circuit and design the PCB from it.

Circuit Design Using PCB Software

To make the circuit compact and give a professional look, I have designed the PCB after testing all the features of the password-based door lock system on the breadboard. I will explain in detail how we can design and order PCB for our project.

Password Based Door Lock System PCB

For the Gerber file check out this link Password Based Door Lock System Gerber File.

Order PCB From PCBWay

I ordered the PCB prototype board from the www.pcbway.com website. PCBWay is a Chinese-based PCB (printed circuit board) prototype, PCB assembly, SMD Stencil, and Flexible PCB manufacturer. They ship to more than 170 countries worldwide and process more than 2100 PCB orders a day. It feels like PCBWay gives an excellent price and customer service factor in one single serving. The quality of the PCB is awesome and its thickness is really great. What is also spectacular about PCBWay to me, as a maker and customer, is their service. From their friendly support staff to their intuitive, user-friendly website features, it all counts towards what makes PCBWay an ideal company and brand for any electronic hobbyists In this article, I will state that how can we order PCB from PCBWay with step by step guide.

Features of PCBWay

1. PCB prototyping and manufacturing

They are not only producing FR-4 and Aluminum boards, but also advanced PCB like Rogers, HDI, Flexible and Rigid-Flex boards, at a very reasonable price.

Visit the link for Instant Quote

Visit the link for Gerber file viewer

2. PCB assembly

SMT & THT assembly starts from only $30 with a free stencil and free worldwide shipping. The components can be sourced and provided by PCBWay, or by clients themselves.

3. Layout and design

Partnering with quality service providers to offer design services.

4. Open source community

Student sponsorship shared PCB projects and so on.

5. 3D Printing & CNC

On-demand Production and Rapid Prototyping in as Fast as 1 Day Leading the Digital Manufacturing Revolution.

Step 1: Go to the PCBWay website and sign up/sign in. Into the PCB Prototype tab, enter the dimensions of your PCB, the number of layers, and the number of PCBs you require. After that proceed by clicking on the ‘Quote Now’ button.

Step 2: You will be redirected to a page where to set a few additional parameters like the board type, layers, material for PCB, thickness, and more, most of them are selected by default, if you are opting for any specific parameters, you can edit it in here.

Step 3: The final step is to upload the Gerber file and proceed with the payment. To make sure the process is smooth, PCBWAY verifies if your Gerber file is valid before proceeding with the payment. This way, you can be sure that your PCB is fabrication friendly.

Working Principle of Password Based Door Lock System

At first, when we power on the circuit, the microcontroller sends commands to the LCD. The LCD displays “enter password”. Now we have to enter the password using the keypad. Once we entered the password, it displays 5 stars on LCD. That is the indication of the controller read password successfully.

Now the controller compares the predefined password and the recently entered password. If those passwords are matched, then the microcontroller makes P0.0 HIGH and P0.1 LOW. It gives motor driver input signals for forwarding motion to the motor.

As a result, the door motor rotates forward direction and the door opens. After 10 seconds the microcontroller makes P0.0 LOW and P0.1 HIGH. Now motor driver gets an input to reverse the motion. So the door motor rotates reverse and the door again locked.

Now if the password does not match, what will happen? The answer is microcontroller maintains both P0.0 and P0.1 LOW. So the door motor does not get any motion and the door remains locked.

Application of Password Based Door Lock System

  • This circuit can be used as a door lock like keylocks.
  • It can be used at highly secure places to secure important documents.
  • With some modifications, this project can be used as a password-based home appliances system.

Advantages of Password Based Door Lock System

  • This project is very simple.
  • The components are very common.
  • Less power consumption.
  • It is a very simple but good security system.

Limitations of Password Based Door Lock System

  • This circuit can not be used remotely.
  • By any chance you forget the password, the door can not be opened.

Microcontroller Code

#include<reg52.h>
sbit r0=P2^0;    sbit r1=P2^1;    sbit r2=P2^2;    sbit r3=P2^3;    sbit c0=P2^5;    sbit c1=P2^6;
sbit c2=P2^7;    sbit en=P3^6;    sbit rs=P3^5;    sbit rw=P3^7;    sbit lock=P3^0;
char t1[]="Enter PIN:";
char t2[]="Access Granted";
char t3[]="Access Denied";
char pin[]="1234";
char pinEntered[4];
unsigned int m = 0;
unsigned int flag = 0;
void delay(unsigned int no)
{
unsigned int i,j;
for(j=0;j<=no;j++)    for(i=0;i<=10;i++); 
}
void lcdcmd(unsigned int  command){
P1=command;    rw=0;    rs=0;    en=0;    delay(1000);    en=1;    delay(1000);    en=0;
}
void lcddata(char data1)
{
P1=data1;    rw=0;    rs=1;    en=0;    delay(1000);    en=1;    delay(1000);    en=0;
}
void lcdint(){
lcdcmd(0x30);    delay(1000);    lcdcmd(0x30);    delay(1000);    lcdcmd(0x30);    delay(1000);
lcdcmd(0x30);    delay(1000);    lcdcmd(0x30);    delay(1000);    lcdcmd(0x38);    delay(1000);
lcdcmd(0x01);    delay(1000);    lcdcmd(0x0F);    delay(1000);    lcdcmd(0x80);    delay(1000);
}
char keypad()
{
char c='a';
while(c!='s'){
r0=0;r1=1;r2=1;r3=1;
if(c0==0){lcddata('1');P0=0xF0;delay(10000);c='s';return '1';}
 if(c1==0){lcddata('2');P0=0xF0;delay(10000);c='s';return '2';}
 if(c2==0){lcddata('3');P0=0xF0;delay(10000);c='s';return '3';}
r0=1;r1=0;r2=1;r3=1;
if(c0==0){lcddata('4');P0=0xF0;delay(10000);c='s';return '4';}
 if(c1==0){lcddata('5');P0=0xF0;delay(10000);c='s';return '5';}
 if(c2==0){lcddata('6');P0=0xF0;delay(10000);c='s';return '6';}
r0=1;r1=1;r2=0;r3=1;
if(c0==0){lcddata('7');P0=0xF0;delay(10000);c='s';return '7';}
 if(c1==0){lcddata('8');P0=0xF0;delay(10000);c='s';return '8';}
 if(c2==0){lcddata('9');P0=0xF0;delay(10000);c='s';return '9';}
r0=1;r1=1;r2=1;r3=0;
//if(c0==0){lcddata('*');P0=0xF0;delay(10000);c='s';return '1';}
 if(c1==0){lcddata('0');P0=0xF0;delay(10000);c='s';return '0';}
// if(c2==0){lcddata('#');P0=0xF0;delay(10000);c='s';return '1';}
}
}
void main()
{
    unsigned int i=0;
    P1=0x00;    P2=0xF0;    P3=0x00;
    lcdint();
    while(1){
    i=0;
    while(t1[i]!='\0')
    {
        lcddata(t1[i]);
        i++;
    }
    lock=0;
    lcdcmd(0xC0);                                                       
    for(i=0;i<=3;i++)
     pinEntered[i] =keypad();
    i=0;
    lcdcmd(0x01);
    if(pinEntered[0]==pin[0])
    {        i++;
        if(pinEntered[1]==pin[1])
        {
            if(pinEntered[2]==pin[2])
            {
                if(pinEntered[3]==pin[3])
                 {
                     lock=1;     i=0;
                             while(t2[i]!='\0')
                                {
                                    lcddata(t2[i]);
                                    i++;
                                }i=0;        
                 }          
            }
        } 
    }else{    i=0;
         while(t3[i]!='\0')
        {
            lcddata(t3[i]);
            i++;
        } i=0; }
    if(i!=0)
    {
 i=0;
         while(t3[i]!='\0')
        {
            lcddata(t3[i]);
            i++;
        }
    }
    delay(1000000);
    lcdcmd(0x01);
    lcdcmd(0x80);
 i=0;    
}  
}

Leave a Comment