Design of password lock based on ATMega16 single chip microcomputer

Publisher:温馨小屋Latest update time:2014-01-07 Source: eefocusKeywords:ATMega16 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

With the development of science and technology, security issues are becoming more and more concerned by people. Various security products have been launched one after another, such as fingerprint anti-theft, infrared anti-theft, etc. Although these products have high security, their cost is also high. It is not convenient to carry and install, which also limits their development. This paper uses ATMega 16 microcontroller, 4×3 keyboard and seven-segment digital tube display, in addition to realizing the basic functions of password verification, reset and input error alarm of the password lock, it also innovatively redefines the keyboard. By redefining the keyboard, it can effectively prevent the password from being stolen, and at the same time reduce the cost and facilitate carrying and installation.

1. Design purpose, use, function

1. Design purpose
With the advancement of science and technology, security issues are becoming more and more concerned by people, and many products have appeared on the market accordingly, such as fingerprint anti-theft, infrared anti-theft, etc. Although its security performance is very high, its cost is also relatively high, and it is not convenient to carry and install. The purpose of this design is to reduce costs and facilitate carrying and installation under the premise of ensuring high security.
2. Design purpose
Since this design has low cost and stable and excellent safety performance, it can be applied to some products with low safety performance requirements and portability, such as home anti-theft, luggage, and car luggage. Its safety performance is far better than the safety of the same cost. The idea of ​​keyboard definition in this design can be transplanted to ATMs, cash withdrawal devices in public places, etc., which can prevent others from peeping and stealing when users enter passwords, and increase the safety of users when withdrawing money.
3. Implementation function
1) Password setting function: By default, the default password is "6666", and the keyboard defaults to
"1 2 3
     4 5 6
     7 8 9
     # 0 *".
When the keyboard is pressed, it is the password input. For each input, the seven-segment digital tube displays "8" and moves one position to the left. If the input is correct, it will display "PASS"; if the input is wrong, it will display "ErOr". If the input error reaches three times, the keyboard will automatically lock and cannot be entered again, and the buzzer will sound an alarm. During the input process, press "*" to delete the wrong number entered, and the display will also move one position to the right.
2) Keyboard redefinition function: When the password is entered correctly, press "#" again to enter the selection and modification function. Enter "#" again to enter the keyboard redefinition function. Press each key in turn, starting from 0, until 9, when the definition ends (the "*" and "#" keys cannot be redefined). During the input process, the buzzer sounds once for each digit entered until the "0~9" are completely redefined. At this time, the digital tube displays "PASS", and the keyboard is the redefined keyboard. When entering the password again, you must enter it according to the redefined keyboard. Similarly, during the input process, press the "*" key to delete the last digit entered.
3) Function reset: When someone enters three wrong digits to trigger the buzzer, the buzzer will keep ringing and sound an alarm until its owner presses the "reset" key to restore all to default.

2. Hardware Design

1. Hardware design ideas

1) Keyboard input: 4×3 matrix keyboard input is used. The three columns correspond to PB0, PB1, and PB2 from left to right, and the four rows correspond to PB4, PB5, PB6, and PB7 from top to bottom.
2) Display: The display uses a common anode seven-segment digital tube display. The four digits correspond to PD0, PD1, PD2, and PD3 from right to left. The abcdefg of the seven-segment digital tube corresponds to ports PA0, PA1, PA2, PA3, PA4.PA5, and PA6.
3) Alarm: When the password is entered incorrectly for three times, the keyboard is locked and a high level is output at port PC0, driving the buzzer to sound continuously. 
2. Circuit schematic diagram

3. Software Design

1. Programming Ideas
1) Keyboard Scanning:
The keyboard scanning program learned in the AVR class uses software de-bouncing to eliminate jitter, "delay_ms(10); //delay de-bouncing". Because the "delay function" is called on the CPU, the CPU cannot perform other tasks within 10ms, thus wasting the CPU and reducing the CPU efficiency. In view of the above defects, we have made great improvements to the keyboard scanning program. By combining the timer interrupt with the comparison interrupt, the CPU can continue to perform other tasks between the two confirmations of whether the key is pressed, thereby improving the CPU efficiency.
2) Display of the seven-segment digital tube
In view of the actual situation of this experiment: when the password passes and the keyboard is redefined, the seven-segment digital tube displays "PASS", and when an error occurs, it displays "ErOr". Therefore, in order to improve the efficiency of the program operation, the pointer variable output method is used, that is, the display of "PASS" and "ErOr" is pre-stored in the memory. When needed, the pointer variable points to the corresponding memory display. For the display of each input bit shifted left, the dynamic scanning method is used.
3) Buzzer alarm:
Output high level to PC7 port to drive the buzzer to sound an alarm.

Keywords:ATMega16 Reference address:Design of password lock based on ATMega16 single chip microcomputer

Previous article:Application of SD card in circuit breaker offline tester
Next article:Design based on Atmega128 embedded controller

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号