DCMC Capstone
DCMC Capstone
submitted by
AKASH S (71812211005)
DEEPAK K (71812211011)
KIRUBAKARAN S (71812211032)
of
for
Course Coordinator
Mr. K. RAJESHWARAN, AP/ECE
SRI RAMAKRISHNA ENGINEERING COLLEGE
[Educational Service: SNR Sons Charitable Trust]
[Autonomous Institution, Reaccredited by NAAC with ‘A+’ Grade]
[Approved by AICTE and Permanently Affiliated to Anna University, Chennai]
[ISO 9001:2015 Certified and all eligible programmes Accredited by NBA]
VATTAMALAIPALAYAM, N.G.G.O. COLONY POST, COIMBATORE- 641 022.
ASSESSMENT
Implementation (4)
Abstract (2)
Report (4)
S. Total
NAME & ROLL NUMBER
No. (10)
1 AKASH S (71812211005)
2 DEEPAK K (71812211011)
3 KIRUBAKARAN S (71812211032)
2
CONTENT
Page
S. No. TITLE
Number
1 AIM 4
2 ALGORITHM 4
3 CIRCUIT DIAGRAM 5
4 COMPONENTS REQUIRED 5
6 WORKING PRINCIPLE 7
7 MICROCONTROLLER CODE 7
3
Password Based Door Lock System Using 8051 Microcontroller
AIM
DESCRIPTION
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 door on the LCD. If the password does not match the door
remains closed and it displays “PWD is wrong” on LCD.
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 the 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.
4
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
5
8051 MICROCONTROLLER CONNECTIONS
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 works 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 for 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 criterion 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 pins 18 and 19 of the microcontroller.
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.
Hence, we complete connecting all the parts of this circuit. Now we have to compile
with the code. Keli μ Vision software is used here to write the program in C language.
Some basic steps are to be followed like creating a new project and selecting 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.
6
WORKING PRINCIPLE
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 the 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 the 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, the microcontroller maintains both P0.0 and
P0.1 LOW. So, the door motor does not get any motion and the door remains locked.
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;
}
7
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;
8
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;
}
}