89c51 Microcontroller Digital door lock working principle
Note: A numeric password is hard coded in the 8051 microcontroller code.
Door lock with 8051 microcontroller-Project requirements
- 8051(89c51,89c52) microcontroller
- 16×2 lcd
- 4×3 numeric keypad
- Lock system
- crystal (11.0592 MHz)
- Bread board(on which circuit is designing)
- Reset circuitry(capacitor(10 uf) and resistor(8.2 K ohm))
- Power supply
Door lock with 89c51 microcontroller – Circuit diagram
Door lock system
A small dc motor is attached to the transistor at the source. Dc motor is operating on 9 volts. Transistor gate is connected to port 3 pin 0. So when the user inputs the correct password the transistor becomes on and our dc motor rotates and move back lock needle, which opens the lock. To lock the door again manually pull up the lock needle.
8051 microcontroller door lock code
Then some character arrays are defined. These character arrays contains the messages that are displayed on the 16×2 lcd when every certain condition is met or their is some wrong input.The password is manually set in the code it is “1234“. You can change it according to your desire but be sure that the password length should not be greater than 4 characters. The lock controlling pin is also defined as lock at Port-3 pin-0.
Functions used in door lock code
- void delay() Generating variable delay.
- void cmd() Sending commands to 16×2 lcd.
- void lcddata() Sending data to 16×2 lcd.
- void lcdint() Initializes 16×2 lcd.
- char keypad() Scaning keypad keys and taking input from user.
- void main() Main function.
Filed Under: 8051 Microcontroller, Microcontroller Projects