introduction
Electronic code lock is a commonly used encryption tool in modern life. It overcomes the shortcomings of mechanical password locks with small passwords and poor security performance, especially the smart electronic password locks with microcontrollers; it not only has the function of an electronic password lock, but also introduces intelligent management functions, so that the password lock has More security and reliability.
Electronic combination locks are usually controlled by ARM and microcontroller. Compared with ARM, microcontroller is simpler to implement and has more complete functions, so it is more controlled by microcontroller. Cellar code locks controlled by microcontrollers often use assembly language to write programs, and most displays use digital tubes. The electronic key lock introduced in this article is written in C language, a high-level language with strong portability and readability, which is easy to modify and add or delete functions. It also uses a 1602 LCD display with clear display, low power consumption and long life, making the display more intuitive. , more convenient to use. From an economic and practical point of view, an electronic password lock with password setting, alarm and prevention of multiple password attempts was designed using STC89C52 microcontroller, and was successfully simulated through Protues software.
1. System working principle
This system takes the STC89C52 microcontroller as the core, uses a 4X4 matrix keyboard as the data input method, and drives the 1602 display to prompt the program running process and specific steps. The password judgment process of this system is as follows:
When the user enters the 6-digit password and presses the BESURE button, the microcontroller compares the passwords one by one. If the entered 6-digit password is exactly the same as the set password, the * simulation light can be successfully driven to open the lock. If the 6-digit password entered is not the same as the set password, and the analog light does not light up after pressing the BESURE button, you can press the BACK button to re-enter. Since it is inevitable to make mistakes when entering the password, if you enter the wrong password, you can directly save the BACK key and re-enter it. However, the system does not allow unlimited pressing of the BACK key to prevent the password from being applied. When the password is entered incorrectly three times, the microcontroller will drive Buzzer alarm. Moreover, this system has a time limit for entering the password. If the correct password is not entered within the specified time, an alarm will be issued.
The password modification function is as follows: when the password is entered correctly, press the SET key to set a new password. Each time a new password is set, the microcontroller sends it to the EPROM. When all 6 new passwords are entered, the system will automatically return to the beginning of the program, re-read the password and save it. The user needs to enter a new password to lock the lock. Open.
2. System design
2.1 Hardware support
The components used are: core chip STC89C52, memory chip AT24C02, LCD display 1602, matrix keyboard, alarm buzzer, independent button (simulation door switch), light-emitting diode (simulation lock switch) and transistor (amplification current) .
2.2 Software design
本系统软件包插主程序模块、甯码比较判断模块、修改密码模块、键盘扫描模块、液晶显示模块及定时程序等模块。系统程序流程如图1所示。
Figure 1 System program flow chart
2.2.1 Main program module
The master sequence is mainly used to define global variables, assign initial values to global variables, initialize EPROM, start the timer and read passwords from AT24C02 to provide data for the entire program.
2.2.2 Password comparison and judgment module
The function of this module is to compare the password entered by the keyboard with the set password one by one using the IF statement. If the password is completely correct, *; if it is incorrect, press the BACK key and re-enter the password. Each time the BACK key is pressed, The number of inputs will be incremented by 1. When all 3fi are wrong, an alarm will be issued.
2.2.3 Password modification module
When the cellar code is entered correctly, you can press SET to reset the password. Each time a digit is set, the password is sent to AT24C02 for storage. When the 6-digit password is set, the system will automatically jump to the beginning of the program and call the new password. The set code.
STC89C52 writes the codon subroutine to AT24C02:
void wrtte_byte(uchar date)
STC89C52 reads codon program from AT24C02:
2.2.4 Keyboard scanning module
This module has functions such as: scanning the keyboard column by column for the specific position of the pressed key, determining whether a key is pressed on the keyboard, eliminating jitter, and determining whether a closed key is released.
2.2.5 Timing module
This module is used to control the password input time. When the program is running, the timer is first initialized. Starting from pressing the PUT IN key, the system starts timing. When the input time reaches the specified time, it will immediately alarm.
2.2.6 LCD module
This module includes LCD initialization, command input, and display data input. The commands are used to control whether the LCD status displays the cursor, whether the cursor flashes, whether to clear the original data and the specific position of the display. Data display mainly requires that the information to be displayed be displayed on time.
3 System Simulation
To facilitate program height. This article uses Protues simulation, and the simulation diagram is shown in Figure 2.
3.1 System introduction
In Figure 2, U1 is STC89C52, which is the core of the system. The written program is imported into it as a binary file; U2 is AT24C02, and the 5th and 6th pins are connected to P1.2 and P1.3 of the microcontroller respectively; LCD1 is a 1602 liquid crystal Display, pin connection is shown in Figure 2; independent button DOOR, when the door is closed, the button is pressed; D1 is an analog * light, when the password is correct, D1 will light up when the BESURE button is pressed; BUZ1 is a buzzer alarm. After the program is written and imported into the microcontroller, press the start button at the bottom of Figure 2. The 1602 LCD will prompt the operating status of the password lock and the system will start working.
3.2*Function
When the power is turned on, the 1602 LCD displays the Welcome interface. When the PUT IN key is pressed, the display displays PUT IN CODES prompting you to enter the password, as shown in Figure 3. The prompt on the LCD will disappear automatically after a few seconds. In this way, you can enter the correct password, and * will be displayed when entering the password without displaying the entered data. After entering the password, press the BESURE key. If the password entered is correct, D1 will light up (D1 serves as an analog switch for *). If the password is wrong, you can press the BACK key, the program will jump to the loop (start interface), re-enter the password, and the number of input times will increase by one. When incorrect input is made three times, an alarm will be automatically issued, and the time for entering the password must be completed within the specified time, otherwise an alarm will be issued.
3.3 Password setting
After the password is entered correctly, press the SET key to reset the password, and the LCD will display SET CODS. The prompt will automatically disappear after a few seconds, and the password reset will begin. During the password setting process, the set numbers will be displayed. Each time you enter a password, you must press the YES key to confirm. When the set password reaches 6 digits, it will automatically return to the startup interface.
4 Conclusion
(1) Successfully simulated the 1602 LCD display, password*, password setting, prevention of multiple attempts, alarm and other functions.
(2) The program is written in C language, which has strong portability and facilitates the addition, deletion and modification of the system.
Previous article:51 microcontroller serial communication programming
Next article:A/D conversion implementation based on AT89CX051
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- Breaking through the intelligent competition, Changan Automobile opens the "God's perspective"
- The world's first fully digital chassis, looking forward to the debut of the U7 PHEV and EV versions
- Design of automotive LIN communication simulator based on Renesas MCU
- When will solid-state batteries become popular?
- Adding solid-state batteries, CATL wants to continue to be the "King of Ning"
- The agency predicts that my country's public electric vehicle charging piles will reach 3.6 million this year, accounting for nearly 70% of the world
- U.S. senators urge NHTSA to issue new vehicle safety rules
- Giants step up investment, accelerating the application of solid-state batteries
- Guangzhou Auto Show: End-to-end competition accelerates, autonomous driving fully impacts luxury...
- Lotus launches ultra-900V hybrid technology "Luyao" to accelerate the "Win26" plan
- Using FPGA to realize accurate time keeping when GPS is out of step
- [Microchip Live Review] How to use Microchip security solutions to protect IoT devices (including ppt, QA)
- BlueNRG-1/2 Flash operations require mutual exclusion with BLE events
- 1S2192 Parameters
- Does anyone have the BAP protocol in Volkswagen's CAN protocol?
- The Definitive Guide to Automotive Ethernet
- Bluetooth learning notes: analysis of example broadcast data
- (Extra 7) GD32L233 Review - FLASH Read and Write
- ZTE Corporation's "Printed Circuit Board Design Specification" series of standards
- Design of LED emergency lighting controller based on MSP430