mc project
mc project
Submitted by:
JANUARY-APRIL 2025
1. Introduction
2. Statement of Problem
3 Block Diagram
4. Components Required
5. Methodology
6. Results
8. References
Introduction:
As the world grows to be digitally dependent, even doors can now be designed to be
secure and safe. The digital version of the lock and key holds a lot of promising
features. The digital lockbox is securely placed with passwords. In our day-to-day
life, Security is a major problem, and digital code locks have become a significant
part of the security system. Today people are facing more problems about security all
over the world, nowadays security is the most essential issue everywhere in the world
so security of everything gains higher and higher importance in recent years.
Currently, there are alternative solutions for safe boxes. Some of them can be opened
via biometrics and sometimes even PIN. These are usually made by locking and
security companies like Godrej. Main concept behind this project is a lid-latch
opening using a passcode entered through a keypad. We aim to make a more
affordable, yet reliable and effective lockbox from an 8051 Microcontroller.
Statement of Problem:
Design system level solutions or processes for engineering problems that meet the
specified needs with appropriate consideration for public health and safety, and
cultural, societal, and environmental considerations with an understanding of the
limitations.
1. This project can be used as a security checking system to stop access to a box only
for unauthorized persons with the password.
2. To understand the interfacing of 4X4 keypad to the 8051-microcontroller using
multiplexing techniques for entering the digital code in the system
3. To understand the functioning of digital code lock with LCD using 8051
microcontrollers. Engineering Systems, variables, and Parameters to Solve Problems
Block Diagram:
Components Required:
Hardware Requirements-
1. 8051 Microcontroller (AT89S52)
2. 8051 Development board
3. 4x3 matrix Keypad
4. LCD Display
5. A DC motor
6. Relay
7. Power Supply
8. Connecting wires
Software Requirements-
1. Keil µVision
2. Microcontroller Programmer & Willar Software
Methodology:
How It Works:
The system waits for a user to enter a passcode via the keypad.
The entered passcode is displayed on the LCD.
If it matches the predefined password (77777), the door opens, and feedback is
provided via the buzzer.
If it doesn't match, an error message is displayed, and the system asks to try
again.
Programming Algorithm:
System Initialization
Ports and peripherals are configured:
P1 handles keypad rows (P1.0-P1.3) and columns (P1.4-P1.6)
P3.0 controls the door relay
P1.7 drives the buzzer
LCD is connected to P2 and P0
Predefined password "77777" is stored in uid[]
Keypad Scanning Algorithm (scankey())
Implements row-column scanning through four phases:
1. Row Activation: Sequentially ground each row (R1-R4) while keeping others
high
2. Column Polling: Check column pins (C1-C3) for low signal during each row
activation
3. Debouncing: 2ms delay after key detection to filter mechanical noise
4. Key Mapping: Returns corresponding character based on row-column
intersection:
Password Entry & Validation Flow
1. Prompt Display: LCD shows "Enter Passcode" and input field
2. Input Capture:
check() ensures valid keypress using polling loop
Stores 5 digits in id[] array
3. String Comparison: Uses strcmp() to match input with uid[]
4. Access Control:
Match: Triggers buzzer twice and displays "Passcode Matched"
Mismatch: Sounds buzzer once and shows "WRONG Password"
Access Control Functions
1. Door Operation (door_open()):
Activates relay for 5 seconds (P3.0 high)
Shows door status messages on LCD
2. Audible Feedback (sounder()):
Pulses buzzer for 500ms using software delays
Provides both success and error indications
Key Technical Aspects
1. I/O Handling:
Direct port manipulation for fast keypad scanning
Bit-specific addressing using sbit declarations
2. Timing:
Custom delay functions using nested loops
Door remains open for about 5-10 seconds duration
3. Security Considerations:
No encryption of stored password
Simple string comparison vulnerable to timing attacks
No lockout mechanism for repeated failures
Code:
#include<reg52.h>
#include<string.h>
#include<lcd.h>
#include<delay.h>
void delay(int);
void user_id(char);
void check_id();
char scankey();
char check();
void door_open();
void door_close();
void sounder();
sbit relay=P3^0;
sbit r1=P1^0;
sbit r2=P1^1;
sbit r3=P1^2;
sbit r4=P1^3;
sbit c1=P1^4;
sbit c2=P1^5;
sbit c3=P1^6;
sbit buzzer=P1^7;
#define on 1
#define off 0
char uid[]="77777";
//char master[]="*0000";
char id[5];
char ne[5];
void main()
{
char key;
//int count=0;
P2=0x00;
P3=0xf0;
P1=0x7F;
P0=0xff;
LCD_Init();
relay=off;
buzzer=0;
while(1)
{
LCD_Clear();
LCD_DisplayString("System Is Locked");
LCD_DisplayString("Enter Passcode");
delay_sec(3);
LCD_Clear();
LCD_DisplayString("Passcode:");
LCD_GoToLineTwo();
LCD_DisplayString("5 Digits : ");
for(n=0;n<5;n++)
{ key=check();
id[n]=key;
LCD_DataWrite(key);
delay(100);
}
if(strcmp(uid,id)==0)
{ sounder();
sounder();
LCD_Clear();
LCD_DisplayString("Passcode Matched");
}
else
{
sounder();
LCD_Clear();
LCD_DisplayString("WRONG Password");
LCD_GoToLineTwo();
LCD_DisplayString("Try Again");
delay_sec(3);
}
for(n=0;n<5;n++)
{
id[n]=0;
}
}
}
void sounder()
{
buzzer=1;
delay_ms(50000);
buzzer=0;
}
void door_open()
{
LCD_GoToLineTwo();
LCD_DisplayString("Opening The Door");
delay_sec(2);
relay=on;
delay_sec(5);
sounder();
LCD_Clear();
LCD_DisplayString("Closing The Door");
delay_sec(1);
relay=off;
}
char check()
{
char b ='a';
while(b=='a')
{
b=scankey();
}
return b;
}
char scankey()
{
c1=c2=c3=1;
r1=r2=r3=r4=0;
r1=0;r2=r3=r4=1;
if(c1==0)
{
delay(2);
return '1';
}
if(c2==0)
{
delay(2);
return '2';
}
if(c3==0)
{
delay(2);
return '3';
}
r2=0;r1=r3=r4=1;
if(c1==0)
{
delay(2);
return '4';
}
if(c2==0)
{
delay(2);
return '5';
}
if(c3==0)
{
delay(2);
return '6';
}
r3=0;r1=r2=r4=1;
if(c1==0)
{
delay(2);
return '7';
}
if(c2==0)
{
delay(2);
return '8';
}
if(c3==0)
{
delay(2);
return '9';
}
r4=0;r1=r2=r3=1;
if(c1==0)
{
delay(2);
return '*';
}
if(c2==0)
{
delay(2);
return '0';
}
if(c3==0)
{
delay(2);
return '#';
}
return 'a';
}
void delay(int x)
{
int i,j;
for(i=0;i<x;i++)
for(j=0;j<2858;j++);
}
Results:
The project focused on developing a password-based door lock system using a
microcontroller, keypad, LCD display, and relay. The system successfully
demonstrated its ability to control access through password authentication.
Advantages-
1. Enhanced Security: The system adds a layer of security by requiring a
passcode for access.
2. Ease of Use: The keypad and LCD interface make it user-friendly for entering
and verifying passwords.
3. Cost-Effective: The components used are affordable and readily available,
making the system economically feasible.
4. Compact Design: The hardware setup is compact and can be integrated into
doors without significant modifications.
Applications
1. Residential Security: Ideal for homes to secure entrances and restrict
unauthorized access.
2. Office Spaces: Can be used in workplaces to control access to restricted areas
or private offices.
3. Industrial Use: Suitable for securing warehouses or storage rooms with
sensitive equipment or materials.
Limitations
1. No Lockout Mechanism: Repeated incorrect attempts do not lock the system
temporarily, which could lead to security breaches.
2. No Encryption: Passwords are stored as plain text in the program, posing risks
if the code is accessed by unauthorized individuals.
3. No Reset Option: Password is directly implemented in the code, hence no
option for changing password externally.
4. Single User Access: The system is designed for one password only, limiting its
use in multi-user environments.
Ways to Improve
1. Add Lockout Mechanism: Implement a feature that locks the system
temporarily after multiple incorrect password attempts.
2. Use Encryption: Encrypt stored passwords to enhance security and prevent
unauthorized access to the code.
3. Add a Reset Option: After entering correct pin twice, option for changing the
password to the user.
Conclusion:
Website links:
a. https://circuitdigest.com/microcontroller-projects/keypad-interfacing-with-
8051-
microcontroller#:~:text=As%20shown%20in%20above%20circuit,correspo
nding%20ROW%20an%20COLUMN%20no
b. https://www.electronicshub.org/password-based-door-lock-system-using-
8051-microcontroller/