Simulation file and complete source code download address: http://www.51hei.com/bbs/dpj-22586-1.html
Thesis download address: http://www.51hei.com/f/Electronic password lock thesis final draft.docx
Below is the mima.c subroutine:
#include
#include "mima.h"
#include "1602.h"
#include "矩阵键盘.h"
#include "delay_ms.h"
/*Compare password function , return 1 if the password is correct, return 0 if it is incorrect*/
bit mimaduibi(unsigned char *string1,unsigned char *string2)
{
unsigned char count;
for(count = 0; count < 6; count++)
{
if(string1[count] != string2[count])
return 0;
}
return 1;
}
/*Select the password input or password change function, the password input returns A, the password change returns B*/
unsigned char step_choose(void)//Select to input password or modify password processing function
{
uchar key;
key = 0xff;
write_com(0x06);//Address pointer plus 1 after writing a character
write_com(0x01);//Display clear, data pointer clear
lcd_pos(0,0);
write_n_char(" Input password ");
lcd_pos(1,0);
write_n_char(" Press key A ");
while((key != A) && (key != B))
key = keyscan();
return key;
}
/*Password input function, returns 1 if the password is correct, returns 0 if the password is wrong*/
bit input_mima(uchar * mima)//Password input function
{
unsigned char count,key;
lcd_pos(1,0);
for(count = 0; count < 7; count++)
{
delay_ms(100);
if(count < 6)
{
do{key = keyscan();}//Scan keyboard
while(key == 0xff);
if((key != backspace) && (key != A) && (key != enter))//Neither backspace nor confirm key
{
write_data('*');//It is a numeric key display*
mima[count] = key;
// continue;
}
if(key == backspace)//It is a backspace key
{
if(count > 0)
{
lcd_pos(1,--count);//Move the cursor forward one
positionwrite_data(' ');//Clear one
positionmima[count] = ' ';//Write emptylcd_pos
(1,count);
count--;//The password counter decreases by one, because it will be +1 after the loop, so we need to add 1 here
}
}
if(key == enter)//Password input is not completed and error message is returned
{
lcd_pos(0,0);
return(0);
}
}
if(count==6)
{
do{key = keyscan();}
while((key != backspace)&&(key != enter));
if(key == backspace)
{
lcd_pos(1,--count);
write_data(' ');
mima[count]=' ';
lcd_pos(1,count);
count--;
}
if(key == enter)//The number of digits in the password is correct
{
return(1);//Return 1 correct signal
}
}
}
}
Previous article:Single chip electronic password lock program (2)
Next article:Design of ultrasonic voice ranging cane based on single chip microcomputer
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- 【Renovation of old things】 Finished product of graffiti desk lamp
- Prototyped a PCB expansion board
- [Practical sharing] Sharing of analog circuit diagrams commonly used by electronic engineers
- MSP432 MCU realizes speech recognition technology
- Mobile Phone RF Design Skills (Part 2)
- [Evaluation of EC-01F-Kit, an NB-IoT development board] - Temperature, humidity and atmospheric pressure equipment based on GD32F350 (completed)
- Dear experts, please help me, I can't figure out what's wrong
- Digital IC Power Supply Noise Suppression and Decoupling Application Note
- Are there any recommendations for cost-effective and stable GPS or Beidou chips?
- [micropython] BLE function is officially added to ESP32