Door Lock System using
8051 microcontroller.
MICROPROCESSORS AND MICROCONTROLLERS
-VANYA NANDWANI
21BEC0434
DATE: 3/04/23
VANYA NANDWANI MICROPROCESSORS AND MICROCONTROLLERS 21BEC0434
Title of the Project:
Door Lock System using 8051 microcontroller
Aim of the Project:
The following project is made to automatically unlock doors using a
password. This reduces risk of robbery as it’ll not allow outsiders in and also
alarm the owner of someone trying to get in uninvited. To develop this project
8051 microcontroller is used along with a motor driver, LCD and Keypad.
Introduction:
Door lock systems are essential for providing security and privacy to
individuals and businesses. They prevent unauthorized access to buildings,
homes, and other private spaces. Here are some of the key reasons why door
lock systems are important:
Safety and Security: Door lock systems provide a sense of security by
preventing intruders from entering your premises. They also protect your
belongings, valuables, and confidential information from theft and damage.
Control Access: Door lock systems allow you to control who enters your
building or home. With advanced features like keyless entry, you can restrict
access to specific areas or individuals, ensuring that only authorized persons
can access them.
Convenience: Modern door lock systems offer various conveniences such as
remote access, keyless entry, and biometric authentication, which make it
easier to enter and exit a building or home.
Peace of Mind: Knowing that your property is secure and protected gives you
peace of mind. This can help you focus on your work or other activities
without worrying about the safety of your premises.
Compliance: Certain industries, such as healthcare and financial services,
require strict access control measures to comply with regulations. Door lock
systems help organizations meet these requirements by providing audit trails
VANYA NANDWANI MICROPROCESSORS AND MICROCONTROLLERS 21BEC0434
and access logs.
Overall, door lock systems are essential for maintaining privacy, safety, and
security in both residential and commercial settings.
Block Diagram of the project:
LCD
KEYPAD
BUZZER 1 MOTOR
DRIVER
STEPPER
MOTOR
Components Used:
Hardware used:
AT89C51
Keypad
DC Motor
LCD (LM016)
L293D (MOTOR DRIVER)
VANYA NANDWANI MICROPROCESSORS AND MICROCONTROLLERS 21BEC0434
Software used:
Proteus 8 Professional- For circuit
Keil-uVision – For coding of 8051
Concept:
The system is built using an 8051 microcontroller, which serves as the main
control unit for the system.
To enter the password, the user inputs a series of digits using a keypad that is
connected to Port 1 of the microcontroller. The microcontroller processes the
input and compares it with a predefined password for authentication.
The LCD display, which is connected to Port 2 of the microcontroller through
eight data pins, shows the user interface and provides feedback on the
system's status. The Register Select (RS) and Enable (EN) pins of the LCD
are connected to Port 3 of the microcontroller, while the Read-Write (RW)
pin is grounded to allow for writing only.
To control the DC motor, the system uses a Motor Driver IC L293D, which is
interfaced with Port 3 of the microcontroller. The L293D is responsible for
providing the necessary power and signals to the motor to drive it in the
desired direction and speed.
Finally, the system is powered by a 12V battery that is used to supply power
to the DC motor through the L293D. The microcontroller also receives power
from the same source.
Overall, this system provides a secure and user-friendly way to control a DC
motor using a keypad and an LCD display. The use of a microcontroller and a
motor driver IC makes the system more efficient and reliable, while the
battery power source makes it portable and convenient to use in various
settings.
VANYA NANDWANI MICROPROCESSORS AND MICROCONTROLLERS 21BEC0434
Circuit Diagram:
Working:
1. Password Setting: The password is set to "1234" using programming,
which means it is predefined and cannot be changed by the user.
2. Correct Password Input: If the user enters the correct password using the
keyboard, the LCD display will indicate "Correct" and the DC motor will
rotate, resulting in the opening of the door.
3. Incorrect Password Input: If the user enters an incorrect password, the
LCD display will show "Incorrect," and the DC motor will not rotate. This
will result in the door remaining closed.
VANYA NANDWANI MICROPROCESSORS AND MICROCONTROLLERS 21BEC0434
Code Used:
#include<reg51.h> //importing 8051 file
#include<string.h>
sbit RS = P3^0; //initializing pins
sbit EN = P3^1;
sbit IN1 =P3^2;
sbit IN2 = P3^3;
void delay(int a)
{
int i,j;
for(i=0;i<a;i++)
for(j=0;j<255;j++);
}
void cmd(char cm)
{
P2 = cm;
RS = 0;
EN = 1;
delay(1);
EN = 0;
}
void dat(char dt)
{
P2 = dt;
RS = 1;
EN = 1;
delay(1);
EN = 0;
}
void display(char *lcd)
{
while(*lcd != '\0')
{
dat(*lcd);
lcd++;
VANYA NANDWANI MICROPROCESSORS AND MICROCONTROLLERS 21BEC0434
}
}
void lcdint()
{
cmd(0x01);
cmd(0x38);
cmd(0x0E);
cmd(0x80);
void main()
{
char pass[5] = "1234";//etting passcode to “1234”
char pass2[5];
int i=0;
char *ptr;
ptr = pass2;
lcdint();
display("Password-");
pass2[4]='\0';
while(1)
{
while(i<4)
{
P1=0xFE;
if(P1==0xEE)
{
*(ptr+i)='7';
dat('7');
delay(200);
cmd(0x06);
i++;
}
else if(P1==0xDE)
{
*(ptr+i)='8';
VANYA NANDWANI MICROPROCESSORS AND MICROCONTROLLERS 21BEC0434
dat('8');
delay(200);
cmd(0x06);
i++;
}
else if(P1==0xBE)
{
*(ptr+i)='9';
dat('9');
delay(200);
cmd(0x06);
i++;
}
else if(P1==0x7E)
{
*(ptr+i)='/';
dat('/');
delay(200);
cmd(0x06);
i++;
}
P1=0xFD;
if(P1==0xED)
{
*(ptr+i)='4';
dat('4');
delay(200);
cmd(0x06);
i++;
}
else if(P1==0xDD)
{
*(ptr+i)='5';
VANYA NANDWANI MICROPROCESSORS AND MICROCONTROLLERS 21BEC0434
dat('5');
delay(200);
cmd(0x06);
i++;
}
else if(P1==0xBD)
{
*(ptr+i)='6';
dat('6');
delay(200);
cmd(0x06);
i++;
}
else if (P1==0x7D)
{
*(ptr+i)='*';
dat('*');
delay(200);
cmd(0x06);
i++;
}
P1=0xFB;
if(P1==0xEB)
{
*(ptr+i)='1';
dat('1');
delay(200);
cmd(0x06);
i++;
}
else if(P1==0xDB)
{
*(ptr+i)='2';
dat('2');
VANYA NANDWANI MICROPROCESSORS AND MICROCONTROLLERS 21BEC0434
delay(200);
cmd(0x06);
i++;
}
else if(P1==0xBB)
{
*(ptr+i)='3';
dat('3');
delay(200);
cmd(0x06);
i++;
}
else if(P1==0x7B)
{
*(ptr+i)='-';
dat('-');
delay(200);
cmd(0x06);
i++;
}
P1=0xF7;
if(P1==0xE7)
{
*(ptr+i)='C';
dat('C');
delay(200);
cmd(0x06);
i++;
}
else if(P1==0xD7)
{
*(ptr+i)='0';
VANYA NANDWANI MICROPROCESSORS AND MICROCONTROLLERS 21BEC0434
dat('0');
delay(200);
cmd(0x06);
i++;
}
else if(P1==0xB7)
{
*(ptr+i)='=';
dat('=');
delay(200);
cmd(0x06);
i++;
}
else if(P1==0x77)
{
*(ptr+i)='+';
dat('+');
delay(200);
cmd(0x06);
i++;
}
}
while(i==4)
{
if ((strcmp(pass, pass2)) == 0)
{
cmd(0xC0);
display("Correct");
IN1 = 1;
IN2 = 0;
delay(100);
}
else
{
cmd(0xC0);
VANYA NANDWANI MICROPROCESSORS AND MICROCONTROLLERS 21BEC0434
display("Incorrect");
IN1 = 0;
IN2 = 0;
delay(100);
}
}
}
}
Observations and Results:
When Password is entered incorrectly, i.e. when user enters a number other
than the set password 1234, the motor does not rotate and LCD displays
“Incorrect”, Hence the door does not unlock.
When Password is entered correctly i.e. 1234, The motor rotates and hence the
door unlocks. The LCD displays “Correct”
VANYA NANDWANI MICROPROCESSORS AND MICROCONTROLLERS 21BEC0434
VANYA NANDWANI MICROPROCESSORS AND MICROCONTROLLERS 21BEC0434
REFERENCES:
1. "Design and Implementation of a Door Lock System using 8051
Microcontroller" by H. S. Mallikarjunaswamy and M. R. Prasad,
International Journal of Scientific and Research Publications, Volume 3,
Issue 5, May 2013.
2. "Design and Implementation of a Security System using 8051
Microcontroller" by R. K. Gupta and V. K. Panchal, International Journal of
Emerging Technology and Advanced Engineering, Volume 4, Issue 1,
January 2014.
3. "Design of Electronic Door Lock System based on 8051 Microcontroller" by
P. S. Rana and R. K. Gupta, International Journal of Innovative Research in
Science, Engineering and Technology, Volume 3, Issue 8, August 2014.
4. "Design and Implementation of a Smart Door Lock System using 8051
Microcontroller" by R. B. Lakshmi and R. J. Prasad, International Journal of
Innovative Research in Science, Engineering and Technology, Volume 4,
Issue 6, June 2015.
5. "Design and Implementation of an Electronic Door Lock System using 8051
Microcontroller" by S. P. Sharma and P. Singh, International Journal of
Advanced Research in Electrical, Electronics and Instrumentation
Engineering, Volume 4, Issue 9, September 2015.