Electronic Keys & Locks

Password Based Door Lock System using 8051 Microcontroller

The Password-Based Door Lock System employing the 8051 Microcontroller is a simple project designed to provide secure access through a password-protected mechanism. As the traditional mechanical lock and key systems are gradually being replaced by more contemporary locking solutions, this project stands out for its smart integration of both mechanical and electronic components, offering simplicity and exceptional efficiency as its key advantages.

Within this automated locking system, an electronic control assembly governs the activation of an output load based on a password input. This output load can include a motor, a lamp, or various other mechanical or electrical devices.

Our project involves the creation of an electronic code lock system using an 8051 microcontroller, serving as a Password-Based Door Lock System with the 8051 Microcontroller. This embedded system operates straightforwardly by receiving input from a keyboard and executing corresponding actions.

In this system, the 8051 microcontroller plays a pivotal role in showcasing the functionality of a password-based door lock. Upon entering the correct code or password, the door unlocks, granting access to the authorized individual into the secured area. In the event of another person’s arrival, the system will prompt for password input once more. If the entered password is incorrect, the door will remain locked, denying access to the individual.


  • Construction and Output Video
  • Principle Behind the Circuit
  • Circuit Diagram of Password Based Door Lock System
  • Components Required
    • Hardware Requirements
    • Software Requirements
  • How to Design Circuit of Password based Door Lock System?
  • Password Based Door Lock System Circuit Simulation Video
  • Password Based Door Locking System Circuit Operation
    • Password Based Door Lock System Algorithm
  • Advantages of Password Based Door Lock System
  • Applications of Password Based Door Lock System
  • Limitations of Password Based Door Lock System

Construction and Output Video

Principle Behind the Circuit

Central to this circuit is the 8051 controller, serving as its pivotal component. The password entry process relies on a 4×4 Matrix Keypad, with the entered password subsequently compared to a predefined list of passwords.

Upon successful entry of the correct password, the system engages the door motor, causing it to rotate and open the door. Concurrently, the LCD display reflects the door’s status as “open.” Conversely, if an incorrect password is entered, the door will remain securely closed, and the LCD will convey the message “PWD is incorrect.”

Circuit Diagram of Password Based Door Lock System

Components Required

Hardware Requirements

  • 8051 Microcontroller
  • 8051 Development Board
  • 8051 Programmer
  • 4×4 Matrix Keypad
  • 16×2 LCD
  • L293D Motor Driver Board
  • DC Motor
  • 10KΩ Potentiometer
  • Connecting wires
  • Power Supply
  • 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)

Software Requirements

  • Keil µVision IDE
  • Willar Programmer
  • Proteus (for circuit diagram and simulation)

How to Design Circuit of Password based Door Lock System?

In the architecture of a password-based door lock system driven by an 8051 microcontroller, we employ several key components: a Microcontroller (specifically the AT89C52, an 8-bit controller), an L293D Motor Driver, a DC Motor, a 4×4 Matrix Keypad, and a 16×2 LCD display. To power the microcontroller, a +5V DC supply voltage is essential. This regulated 5V DC power is furnished by the 7805 power supply circuit. To meet this power requirement, one can utilize either a 9V DC battery or a 12V 1A converter as a power source.

Reset Circuit Design:

The reset pin of the microcontroller remains active until the power supply reaches the specified range and attains a minimum level of oscillation. To guarantee that the supply voltage remains above the 1.2V threshold and that the reset pulse duration exceeds 100ms (as advised for the 89C52), we need to select resistor and capacitor values in a way that satisfies the condition RC >= 100ms. Consequently, we opted for a 10K resistor in conjunction with a 10µF electrolytic capacitor.

Oscillator Circuit Design:

An external clock signal, operating at 11.0592MHz, is employed to drive the microcontroller. To ensure stable operation, two ceramic capacitors in the range of 30pF to 40pF are required to be connected. These capacitors are linked to pins 18 and 19 of the microcontroller where the crystal oscillator is connected. In this instance, we employed two 33pF capacitors.

Interfacing LCD, Keypad and Motor Driver:

To begin, attach a 10K potentiometer to the LCD Display’s Contrast Adjust Pin (Pin 3). P3.0, GND, and P3.2 pins are used to link the LCD’s RS, RW, and E. The LCD’s eight data lines are attached to PORT1.

The Keypad’s four ROW pins are attached to P2.0 to P2.3, while the Keypad’s four COLUMN pins are connected to P2.4 to P2.7, respectively. IN1 and IN2 of the L293D Motor Driver (1A and 2A) are linked to PORT0 pins P0.0 and P0.1. The motor is linked to the L293D’s OUT1 and OUT2 (1Y and 2Y) pins.

Compilation of Microcontroller Code:

After you’ve designed and mapped out the circuit, the subsequent step involves coding. We opted for the Keil Vision package to write the application in the C language.

Before you commence writing the code, it’s essential to perform routine tasks such as creating a new project and selecting the specific target device or microcontroller you’ll be working with. Once the code is complete, save it with the .c extension and add it to the source file group located within the designated target folder. To compile the code, press the F7 key.

Upon successful compilation, the code generates a hex file. In the next phase, the circuit is implemented using Proteus software. To load the code into the microcontroller, an external device, such as the Willar Software and programmer, is employed.

Password Based Door Lock System Circuit Simulation Video

Before reading about how this circuit works, watch the simulation video below to gain a better understanding of how it works.

Password Based Door Locking System Circuit Operation

Upon activation of the circuit, the microcontroller issues commands to the LCD, prompting it to display the message “enter password.” At this point, it becomes necessary to utilize the keypad for password input. Upon successful input of the password, the LCD presents five stars as feedback, signifying that the controller has effectively recognized the password.

Next, the controller proceeds to compare the entered password with the previously set password. In the event of a correct password match, the microcontroller sets P0.0 to a HIGH state and P0.1 to a LOW state. This action enables the motor driver to receive input signals for forward motion.

Consequently, the Door Motor engages in a forward rotation, facilitating the opening of the door. After a 10-second delay, the microcontroller switches P0.0 to LOW and P0.1 to HIGH, permitting the motor driver to accept input signals for reverse motion. Consequently, the Door Motor reverses its rotation, effectively closing the door.

However, if an incorrect password is entered, the microcontroller maintains both P0.0 and P0.1 in a low state. This action keeps the door motor stationary, ensuring that the door remains securely closed.

NOTE: Make sure there are no common connections between the AC and DC supplies while making the connections.

Password Based Door Lock System Algorithm

  1. Declare the PORT1 to be LCD data pins and the control pins (RS and E) to be P3.0 and P3.2 at first. Declare PORT2 on the keypad as well. P0.0 and P0.1 can also be used for the motor driver.
  2. Then, on the LCD, display the message “input password.”
  3. Now take the user’s five-digit password.
  4. Compare the password you entered with the password you saved.
  5. Make P0.0 pin HIGH and P0.1 pin LOW to open the door if the password is right. Display “Door opening” on the LCD during this moment.
  6. Make P0.0 pin LOW and P0.1 pin HIGH to close the door when some time has passed, and then show “Door closing” on the LCD.
  7. If the password is incorrect, the LCD will display “Wrong Password.”
  8. After some time has passed, you will be asked to enter your password once more.

Advantages of Password Based Door Lock System

  • This project ensures safety.
  • The amount of energy used is reduced.
  • Components that were readily accessible
  • The project is basic and straightforward.

Applications of Password Based Door Lock System

  • This basic circuit can be used to improve safety in residential areas.
  • It can be used in businesses to ensure that only authorised people have access to extremely guarded areas.
  • With a little tweaking, this project may be used to control load switching through password.

Limitations of Password Based Door Lock System

  • It is a low-range circuit, which means it cannot be controlled remotely.
  • It is impossible to open the door if you forget the password.

Related Articles

Leave a Reply

Your email address will not be published.

Back to top button