当前位置:网站首页>B011 - 51-based multifunctional fingerprint smart lock
B011 - 51-based multifunctional fingerprint smart lock
2022-08-01 17:36:00 【little engineer】
任务列表
效果
原理图
设计资料
Because this design uses multiple serial ports,比如使用了GSM通信,Fingerprint communication,Voice broadcast communication,The communication methods used by these three modules and the microcontroller are serial communication,Set the matching baud rate.The system uses a variety of modes of input,矩阵键盘,红外遥控,ICCard input, etc,Therefore, the difficulty of design lies in the integration of multiple modules,The workload of the system is relatively large.The information that explains the testing process is relatively complete.
源代码
/******************************************************************************* * 文件名称:基于51multifunctional fingerprint smart lock * 实验目的:1. * 2. * 程序说明:完整程序Q:2772272579;@: [email protected] * 日期版本:The basic logic is theremain程序.Please contact me for a complete project.可定制. *******************************************************************************/
#include"config.h"
#include"delay.h"
uchar Xuhao_Check();
void KeyPress(uchar keycode);
void set_password(void);
void Timer0Init(void);
u8 EEROM_TEST[10]={
0};
u8 EEROM_CHECK;
/******************** IO配置函数 **************************/
//sbit Lock=P5^4;
sbit Finger_Touch=P4^5;
void GPIO_config(void)
{
GPIO_InitTypeDef GPIO_InitStructure; //结构定义
GPIO_InitStructure.Pin = GPIO_Pin_4; //指定要初始化的IO, GPIO_Pin_0 ~ GPIO_Pin_7, 或操作
GPIO_InitStructure.Mode = GPIO_OUT_PP; //指定IO的输入或输出方式,GPIO_PullUp,GPIO_HighZ,GPIO_OUT_OD,GPIO_OUT_PP
GPIO_Inilize(GPIO_P5,&GPIO_InitStructure); //初始化
GPIO_InitStructure.Pin = GPIO_Pin_0; //指定要初始化的IO, GPIO_Pin_0 ~ GPIO_Pin_7, 或操作
GPIO_InitStructure.Mode = GPIO_PullUp; //指定IO的输入或输出方式,GPIO_PullUp,GPIO_HighZ,GPIO_OUT_OD,GPIO_OUT_PP
GPIO_Inilize(GPIO_P0,&GPIO_InitStructure); //初始化
GPIO_InitStructure.Pin = GPIO_Pin_5; //指定要初始化的IO, GPIO_Pin_0 ~ GPIO_Pin_7, 或操作
GPIO_InitStructure.Mode = GPIO_PullUp; //指定IO的输入或输出方式,GPIO_PullUp,GPIO_HighZ,GPIO_OUT_OD,GPIO_OUT_PP
GPIO_Inilize(GPIO_P4,&GPIO_InitStructure); //初始化
}
unsigned char xdata g_ucTempbuf[20];
uchar xdata Xuhao_Panduan[4];
uchar code Xuhao_SQL[]={
0x49,0X10,0XFC,0XB9, // blue card
0X8C,0XF3,0XC3,0XDE, // 白色卡
};
unsigned char code password_r[6] = {
1,2,3,4,5,6}; //定义初始密码.
unsigned char code password_gl[6] = {
8,8,8,8,8,8}; //Define the administrator password.
unsigned char password[6]; //Define password staging
const unsigned char muntochar[] = {
'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};//1602LCD numbers to characters
unsigned char password_bj[6] = {
20,20,20,20,20,20}; //密码比较
bit password_dis = 1; //声明1个变量,Used to record whether the password is displayed or hidden.
unsigned char in_password_mun = 255; //声明1个变量,Used to record the number of digits entered in the password.
unsigned char flag_Lock = 0; //声明1个变量,Used to record the delay closing time of the password lock.
unsigned int err_time = 0; //声明1个变量,用来记录3The alarm time for the wrong password input
unsigned char password_start = 0; //声明1个变量,Used to record key-press delay time.达到3Second password reset.
bit password_ok_open = 0; //定义1个变量,Used to record the correct password input flag,0表示不成功.1表示成功.
unsigned char password_err_mun = 0; //声明1A variable is used to record the number of times the password is entered incorrectly.
bit flag_200ms = 0; //定义200mS标志位.为1表示200MS到,为0said it did not arrive.
bit Flag_FPM10A_Set=0; //Fingerprint settings:1;正常检测:0
char local_date=0,base_date=0;//全局变量,Current arrow position
bit Flag_SIMSendWarning=0;//Send alarm SMS sign
unsigned char SIM_Commend01[]="123456open" ; //unlock command
unsigned char SIM_Commend02[]="123456close" ; //Lock command
uchar Card_Erro=0,Finger_Erro=0;
void main()
{
unsigned char keycode; //声明1个变量,Used to temporarily store key values.
unsigned char status=0,i=0,Client=0;
uchar IR_Rec=0,IR_value=99;
int ret=0; //GSM信号提示
EX0init(); TIM1_Init();
GPIO_BuzzConfig();
GPIO_config();
Keyboard_GPIO_Config();
Init_1602();
write_string(1,0," Welcome To Use ");
write_string(2,0," System Init... ");
delay_ms(1000);
UART4_Init();
Device_Check(); //Check whether the fingerprint module is connected correctly,The LCD makes corresponding prompts
write_com(0x01); //清屏
EEPROM_read_n(EEROM_USEADDR,&EEROM_CHECK,1);
if(EEROM_CHECK == EEROM_CHECK_VALUE) //old microcontroller,Password stored
{
EEPROM_read_n(EEROM_USEADDR+1,password,6);
}
else
{
Beep=0;
delay_ms(200);
EEPROM_write_n(EEROM_USEADDR,password_r,6);
Beep=1;
}
/*----GSMConfigure the LCD display----*/
write_com(0x01); //清屏
write_string(1,0," GSM Config ");
write_string(2,0," Waiting.... ");
Timer0Init();
UART2_Init();
for(i = 0;i < STABLE_TIMES;i++)//等待GSM网络稳定
{
delay_20ms(1);
}
ret = check_status(); //初始化配置
if(ret == 1)
{
write_string(2,0,"Docking success");
delay_ms(200);
ret = config_format();//配置
if(ret == 1)
{
write_string(2,0,"Config success");
delay_ms(500);
}
else
{
write_string(2,0,"Config failure");
delay_ms(500);
}
}
else
{
write_string(2,0,"Docking failure");
delay_ms(500);
}
CLR_Buf();//Clear the serial port array,准备接收 GSM信息
/*----Turn on the LCD display----*/
write_com(0x01); //清屏
write_string(1,0," Password Lock ");
write_string(2,0," Input: ");
PcdGpioConfig();
PcdReset(); //功 能:复位RC522
PcdAntennaOff(); //关闭天线
delay_ms(2);
PcdAntennaOn(); //开启天线 每次启动或关闭天险发射之间应至少有1ms的间隔
UART3_Init();
delay_ms(1000);
MX_6x00SendCmd(MX_SET_VOL,0x14); //设置音量 0x00-0x1E :0-30
delay_ms(100);
MX_6x00SendCmd(MX_SET_CYCLICAL,MX_CYCLICAL_SINGLE_STOP); //设置播放模式:单曲停止
delay_ms(100);
MX_6x00SendCmd(SPECIFIED_SONG,1);//播报语音
while(1)
{
if(Flag_FPM10A_Set) //Fingerprint setting interface
{
if(local_date==0)
{
LCD1602_Display(0x80, " *",0,2); // LCD1602_Display(0x80, "FSFSFSF",5,2);
LCD1602_Display(0xc0, " ",0,2);
LCD1602_Display(0xc0+8," ",0,2);
}
else if(local_date==1)
{
LCD1602_Display(0x80, " ",0,2);
LCD1602_Display(0xc0, " *",0,2);
LCD1602_Display(0xc0+8," ",0,2);
}
else if(local_date==2)
{
LCD1602_Display(0x80, " ",0,2);
LCD1602_Display(0xc0, " ",0,2);
LCD1602_Display(0xc0+8," *",0,2);
}
keycode = Getkeyboard();
//有效键值0-15
if (keycode<16)
{
Buzz_Times(1);
if(keycode==13)//确认键
{
switch(local_date)
{
case 0: //搜索指纹
FPM10A_Find_Fingerprint();
write_com(0x01); //清屏
/**************Return to the main function interface****************/
write_string(1,0," search finger "); //The first row shows the search fingerprint
write_string(2,0," Add delete"); //添加和删除指纹
break;
case 1: //添加指纹
FPM10A_Add_Fingerprint();
write_com(0x01); //清屏
/**************Return to the main function interface****************/
write_string(1,0," search finger "); //The first row shows the search fingerprint
write_string(2,0," Add delete"); //添加和删除指纹
break;
case 2: //清空指纹
FPM10A_Delete_All_Fingerprint();
write_com(0x01); //清屏
/**************Return to the main function interface****************/
write_string(1,0," search finger "); //The first row shows the search fingerprint
write_string(2,0," Add delete"); //添加和删除指纹
break;
}
}
//切换键
if(keycode == 12)
{
if(local_date<=2)
{
local_date++;
if(local_date==3)
local_date=0;
}
}
if(keycode == 10)
{
Flag_FPM10A_Set=!Flag_FPM10A_Set;
if(Flag_FPM10A_Set)
{
write_com(0x01); //清屏
/**************Return to the main function interface****************/
write_string(1,0," search finger "); //The first row shows the search fingerprint
write_string(2,0," Add delete"); //添加和删除指纹
}
else
{
write_com(0x01); //清屏
/*----Turn on the LCD display----*/
write_string(1,0," Password Lock ");
write_string(2,0," Input: ");
}
}
}
}
else //正常界面
{
if(find_string_flag == 1)
{
delay_ms(1000);//延时一点,让串口把数据接收完成
if(Find("+CMTI"))//说明接收到了短信
{
ret = read_message();
if(ret == 1)
{
for(i=0;i<6;i++)
{
SIM_Commend01[i]= password[i]+0x30; //Replace with the correct password
SIM_Commend02[i]= password[i]+0x30;
}
if(Find(SIM_Commend01))
{
Lock=0;
MX_6x00SendCmd(SPECIFIED_SONG,2);//播报语音
extract_phone_number();
ret = send_text_message("The lock is open.");
password_ok_open = 1; //The password is correct1,表示输入成功.
password_err_mun = 0; //The number of incorrect passwords is cleared0.
write_string(2,0," Input: "); //Show restore.
write_com(0XC7); //液晶AC控制到第2行的第7位置.
for(i = 0;i < 6;i++) //循环6次
password_bj[i] = 20; //Set the password to compare the numbers in the array back to20.
in_password_mun = 255; //Record password input digits to restore.
}
if(Find(SIM_Commend02))
{
if(Lock==0)
Lock=1;
extract_phone_number();
ret = send_text_message("The lock is closed.");
}
}
CLR_Buf();
}
CLR_Buf();
}
if(Finger_Touch) //Finger press detected,Jump to Fingerprint detection
{
Finger_Erro+=FPM10A_Find_Fingerprint_Touch();
}
IR_Rec=Handle_Hongwai();
if(IR_Rec!=0)
{
Buzz_Times(1);
IR_value=IR_code(IR_Rec);
/*=======Password input processing========*/
if(IR_value < 10) //If the entered key value is a numeric key
{
in_password_mun++; //Enter each digit of the password,The number of digits is incremented1.
if(in_password_mun == 6) //The number of digits to enter the password is controlled6位
in_password_mun = 5;
password_bj[in_password_mun] = IR_value; //Store the key value in the password comparison array
if(password_dis == 0) //If the password is displayed.输入密码显示
{
write_com(0XC7); //液晶AC控制到第2行的第7位置.
for(i = 0;i < 6;i++) //循环检查6位密码,and displayed on the screen
{
if(password_bj[i] != 20) //If not the original value,Indicates that there is a new password
write_date(muntochar[password_bj[i]]); //Display the new password on the screen
}
}
if(password_dis == 1) //If the password is hidden.就显示*号
{
write_com(0XC7); //液晶AC控制到第2行的第7位置.
for(i = 0;i < 6;i++) //循环检查6位密码,and displayed on the screen
{
if(password_bj[i] != 20) //If not the original value,Indicates that there is a new password
write_date('*'); //Enter the password with *号显示出来.
}
}
}
else
KeyPress(IR_value);
}
keycode = Getkeyboard();
//有效键值0-15
if (keycode<16)
{
Buzz_Times(1);
/*=======Password input processing========*/
if(keycode < 10) //If the entered key value is a numeric key
{
in_password_mun++; //Enter each digit of the password,The number of digits is incremented1.
if(in_password_mun == 6) //The number of digits to enter the password is controlled6位
in_password_mun = 5;
password_bj[in_password_mun] = keycode; //Store the key value in the password comparison array
if(password_dis == 0) //If the password is displayed.输入密码显示
{
write_com(0XC7); //液晶AC控制到第2行的第7位置.
for(i = 0;i < 6;i++) //循环检查6位密码,and displayed on the screen
{
if(password_bj[i] != 20) //If not the original value,Indicates that there is a new password
write_date(muntochar[password_bj[i]]); //Display the new password on the screen
}
}
if(password_dis == 1) //If the password is hidden.就显示*号
{
write_com(0XC7); //液晶AC控制到第2行的第7位置.
for(i = 0;i < 6;i++) //循环检查6位密码,and displayed on the screen
{
if(password_bj[i] != 20) //If not the original value,Indicates that there is a new password
write_date('*'); //Enter the password with *号显示出来.
}
}
}
else
KeyPress(keycode);
}
status = PcdRequest(PICC_REQALL, g_ucTempbuf);//寻卡
delay_ms(20);
if(status == MI_OK ) //If you get a card,Then judge the card serial number
{
status = PcdAnticoll(g_ucTempbuf);//防冲撞
if (status != MI_OK)
{
}
for(i=0;i<4;i++) //卡序列号
{
Xuhao_Panduan[i]=g_ucTempbuf[i];
// write_hex(2,0+i*2,Xuhao_Panduan[i]);
}
delay_ms(1000);
Client=Xuhao_Check();
if(Client!=0)
{
Lock=0;
MX_6x00SendCmd(SPECIFIED_SONG,2);//播报语音
password_ok_open = 1; //The password is correct1,表示输入成功.
password_err_mun = 0; //The number of incorrect passwords is cleared0.
write_string(2,0," Input: "); //Show restore.
write_com(0XC7); //液晶AC控制到第2行的第7位置.
for(i = 0;i < 6;i++) //循环6次
password_bj[i] = 20; //Set the password to compare the numbers in the array back to20.
in_password_mun = 255; //Record password input digits to restore.
}
else //Unregistered card
{
write_string(2,0,"CardUnregistered"); //Show restore.
Card_Erro++;
Buzz_Times(3);
write_string(2,0," Input: "); //Show restore.
}
}
else //Did not get the card
{
PcdReset();
PcdAntennaOff();
delay_ms(2);
PcdAntennaOn();
}
//标记1
if(flag_200ms == 1) //如果200ms时间到.
{
flag_200ms = 0; //200ms标志清0
/*--------Delay to close the lock---------*/
if(Lock == 0) //If the lock is open.
{
Flag_SIMSendWarning=0; // SMS alarm resumes
err_time = 0; //Error alarm delay clear0.
password_err_mun = 0; //The number of errors is cleared0.
Card_Erro=0;
Finger_Erro=0;
Beep = 1;
flag_Lock++; //The lock delay is automatically incremented
if(flag_Lock >= 5 * 10) //If the delay arrives10秒
{
flag_Lock = 0; //Delay clear0.
Lock = 1; //关闭密码锁
password_err_mun = 0; //The number of errors is cleared0.
Card_Erro=0;
Finger_Erro=0;
}
}else //如果锁是关闭的.
flag_Lock = 0; //Delay clear0.
/*--------输入错误密码3次,报警1分钟---------*/
if(password_err_mun >= 3 || Card_Erro>=3 || Finger_Erro>=3)
{
err_time ++; //The error alarm delay is automatically incremented
Beep = 0; //蜂鸣器报警
if(Flag_SIMSendWarning==0)
{
send_text_message_set("Alert, Trespass!!!"); //Send an alarm SMS once
Flag_SIMSendWarning=1;
}
if(err_time >= 5 * 20) //如果达到20S
{
Flag_SIMSendWarning=0; // SMS alarm resumes
err_time = 0; //Error alarm delay clear0.
password_err_mun = 0; //The number of errors is cleared0.
Card_Erro=0;
Finger_Erro=0;
Beep = 1;
}
}
}
}
} //while
}
//按键响应程序,Parameters are key-values
//返回键值:
// 1 2 3 10 //10: Fingerprint interface/正常界面
// 4 5 6 11 //11: 修改密码
// 7 8 9 12 //12: 手动关闭锁
// 14 0 15 13 //14:显示/隐藏输入的密码 15:删除 13:确认
void KeyPress(uchar keycode)
{
uchar i=0;
switch (keycode)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
break;
case 15: /*---------功能(删除1位密码)-----------*/
if(in_password_mun != 255)
{
password_bj[in_password_mun] = 20;
write_com(0XC7 + in_password_mun); //液晶AC控制到第2行的第7位置.
write_date(' ');
write_com(0XC7 + in_password_mun); //液晶AC控制到第2行的第7位置.
if(in_password_mun > 0)
in_password_mun--;
else
in_password_mun = 255; //Record password input digits to restore.
}
break;
case 13: /*---------功能(确定密码是否正确)-----------*/
for(i = 0;i < 6;i++) //Compare the input password first
{
if(password[i] != password_bj[i]) //如果密码不匹配.
break; //跳出for循环.
if(i == 5) //如果循环6times did not jump outfor循环,密码输入正确.
{
password_ok_open = 1; //The password is correct1,表示输入成功.
password_err_mun = 0; //The number of incorrect passwords is cleared0.
}
}
if(password_ok_open != 1) //If the password is entered incorrectly,Check the administrator password again if the relay is not turned on,Indicates that the password was entered incorrectly
{
for(i = 0;i < 6;i++) //比较6位密码.
{
if(password_bj[i] != password_gl[i]) //如果密码不匹配.
{
password_err_mun++; //The number of incorrect passwords increases automatically1.
write_string(2,0," Error ");
write_date(muntochar[password_err_mun]); //The number of incorrect password entries is displayed on the screen
write_string(2,12," ");
Beep = 0; //Beep prompt.
delay_ms(150);
Beep = 1;
delay_ms(250);
Beep = 0;
delay_ms(350);
Beep = 1;
break; //跳出for循环.
}
if(i == 5) //如果密码输入正确.
{
password_ok_open = 1; //The password is correct1,表示输入成功.
password_err_mun = 0; //The number of incorrect passwords is cleared0.
}
}
}
if(password_ok_open != 1) //如果密码错误,延时一段时间.
{
delay_ms(450); //延时一段时间.
Beep = 0;
delay_ms(550);
Beep = 1;
}
else //如果正确.
{
Lock = 0; //打开继电器,Password lock open.
MX_6x00SendCmd(SPECIFIED_SONG,2);//播报语音
password_ok_open = 0; //The password input success flag is set.
}
write_string(2,0," Input: "); //Show restore.
write_com(0XC7); //液晶AC控制到第2行的第7位置.
for(i = 0;i < 6;i++) //循环6次
password_bj[i] = 20; //Set the password to compare the numbers in the array back to20.
in_password_mun = 255; //Record password input digits to restore.
break;
case 14: /*---------功能(显示输入密码)-----------*/
if(password_dis == 1)
{
write_com(0XC7); //液晶AC控制到第2行的第7位置.
for(i = 0;i < 6;i++)
{
if(password_bj[i] != 20)
write_date(muntochar[password_bj[i]]);
}
}
if(password_dis == 0)
{
write_com(0XC7); //液晶AC控制到第2行的第7位置.
for(i = 0;i < 6;i++)
{
if(password_bj[i] != 20)
write_date('*');
}
}
password_dis = !password_dis;
break;
case 11: /*---------功能(设置密码)-----------*/
if(Lock == 0) //If the password setting button is pressed,And the combination lock is open.
{
set_password(); //Enter password settings.
Lock = 1; //The combination lock is closed.
for(i = 0;i < 6;i++) //循环6次,清空密码
password_bj[i] = 20; //Set the password to compare the numbers in the array back to20.
in_password_mun = 255; //Record password input digits to restore.
}
break;
case 12: /*---------功能(Close the combination lock manually)-----------*/
if(Lock == 0) //If the manual closing lock button is pressed,And the combination lock is open.
Lock = 1; //The combination lock is closed.
break;
case 10:
if(Lock == 0)
{
Flag_FPM10A_Set=!Flag_FPM10A_Set;
if(Flag_FPM10A_Set)
{
write_com(0x01); //清屏
/**************进入主功能界面****************/
write_string(1,0," search finger "); //The first row shows the search fingerprint
write_string(2,0," Add delete"); //添加和删除指纹
}
else
{
write_com(0x01); //清屏
/*----Turn on the LCD display----*/
write_string(1,0," Password Lock ");
write_string(2,0," Input: ");
}
}
break;
default:break;
}
}
uchar Xuhao_Check()
{
uchar i=0;
for(i=0;i<4;i++)
{
if(Xuhao_Panduan[i]==Xuhao_SQL[i])
continue;
else
break;
}
if(i==4)
{
return 1; //identified as a customer1 :green card
}
for(i=0;i<4;i++)
{
if(Xuhao_Panduan[i]==Xuhao_SQL[i+4])
continue;
else
break;
}
if(i==4)
{
return 2; //identified as a customer2 :白色卡
}
else
{
return 0; //not in the database
}
}
void Timer0Init(void) //1毫秒@11.0592MHz
{
AUXR &= 0x7F; //定时器时钟12T模式
TMOD &= 0xF0; //设置定时器模式 16Bit self-reloading
TL0 = 0x66; //设置定时初值
TH0 = 0xFC; //设置定时初值
TF0 = 0; //清除TF0标志
TR0 = 1; //定时器0开始计时
ET0=1;
EA=1;
}
static void Timer0_irt()interrupt 1
{
static unsigned int time_add = 0,time_add02=0; //Declare a variable to record the number of interruptions,achieve the purpose of timing.
time_add ++; //记录中断次数
if(time_add == 200) //200mS
{
flag_200ms = 1; //200mS标志置位
time_add = 0; //Clear time records0
}
time_add02++;
if(time_add02 == 20)
{
time_add02=0;
if(count_20ms > 0) //20ms延时计数器
{
count_20ms--;
}
}
}
/*==================密码设置==================*/
void set_password(void)
{
unsigned char key_16mun; //声明1个变量,Used to temporarily store the value of the key.
unsigned char in_password_mun = 255; //声明1个变量,Used to record the number of digits entered in the password.
unsigned char intput = 1; //声明1个变量,Used to record is the input section1Second or first2密码
unsigned char password1[] = {
20,20,20,20,20,20}; //temporary storage1次输入的密码
unsigned char password2[] = {
20,20,20,20,20,20}; //temporary storage2次输入的密码
unsigned char i; //声明1个变量,for recycling.
unsigned char out_time = 0; //声明1个变量,Used to record the no-operation automatic exit time
/*----Turn on the LCD display----*/
write_string(1,0,"Input1: "); //LCD display characters
write_string(2,0,"Input2: "); //LCD display characters
write_com(0X87); //液晶AC控制到第1行的第7位置.
while(1)
{
key_16mun = Getkeyboard(); //Temporarily save the scanned key value,方便处理.
if(key_16mun != 99) //只要有按键按下,Just beep.
{
Beep = 0; //beep on.
delay_ms(100); //延时一段时间.
Beep = 1; //Beep off.
out_time = 0; //Clear exit time.
}
/*=======Password input processing========*/
if(key_16mun < 10) //If the entered key value is a numeric key
{
in_password_mun++; //Enter each digit of the password,The number of digits is incremented1.
if(in_password_mun == 6) //The number of digits to enter the password is controlled6位
in_password_mun = 5;
if(intput == 1) //如果是第1次输入新密码.
{
password1[in_password_mun] = key_16mun; //Store the key value in the 1Array of temporary passwords
write_com(0X87); //液晶AC控制到第1行的第7位置.
for(i = 0;i < 6;i++) //循环检查6位密码,and displayed on the screen
{
if(password1[i] != 20) //If not the original value,Indicates that there is a new password
{
if(password_dis == 0)
write_date('*'); //Enter the password with *号显示出来.
else
write_date(muntochar[password1[i]]);
}
}
}
else //如果是第2次输入的密码
{
password2[in_password_mun] = key_16mun; //Store the key value in the 2Array of temporary passwords
write_com(0Xc7); //液晶AC控制到第2行的第7位置.
for(i = 0;i < 6;i++) //循环检查6位密码,and displayed on the screen
{
if(password2[i] != 20) //If not the original value,Indicates that there is a new password
{
if(password_dis == 0)
write_date('*'); //Enter the password with *号显示出来.
else
write_date(muntochar[password2[i]]);
}
}
//主要目的为 * Toggle display with physical password,The password value entered for the first time is taken into account----------------------------
write_com(0X87); //液晶AC控制到第1行的第7位置.
for(i = 0;i < 6;i++) //循环检查6位密码,and displayed on the screen
{
if(password1[i] != 20) //If not the original value,Indicates that there is a new password
{
if(password_dis == 0)
write_date('*'); //Enter the password with *号显示出来.
else
write_date(muntochar[password1[i]]);
}
}
//------------------------------------------------------------
}
}
/*---------功能(确定密码是否正确)-----------*/
if(key_16mun == 13) //If the OK key is pressed.
{
if(intput == 1) //如果是第1次输入密码
{
intput = 2; //Logo pp2次输入密码
in_password_mun = 255; //Password input digits record restoration
write_com(0Xc7); //液晶AC控制到第2行的第7位置.
}
else //If a new password has been entered twice,比较密码是否一致.
{
for(i = 0;i < 6;i++) //比较6位密码.
{
if(password1[i] != password2[i]) //如果密码不匹配.
{
write_string(1,0,"Password failed!");//Displays the word inconsistency of the password
write_string(2,0," N0 ! ");//Displays the word inconsistency of the password
break; //跳出for循环.
}
if(i == 5) //如果循环6times did not jump outfor循环,密码输入正确.
{
write_string(1,0,"Password success");//Displays the word inconsistency of the password
write_string(2,0," OK ! ");//显示密码修改成功.
EEPROM_write_n(EEROM_USEADDR,password1,6); //Write the modified password
EEPROM_read_n(EEROM_USEADDR+1,password,6); //读取6位密码.存入password数组.
}
}
Beep = 1; //Beep prompt.
delay_ms(250);
Beep = 0;
delay_ms(150);
Beep = 1;
delay_ms(250);
delay_ms(250);
Beep = 0;
delay_ms(250); //延时退出.
delay_ms(250);
delay_ms(250);
Beep = 1; //The beep turns off.
/*----The LCD returns to the standby state display----*/
write_string(1,0," Password Lock "); //LCD display characters
write_string(2,0," Input: "); //LCD display characters
write_com(0XC7); //液晶AC控制到第2行的第7位置.
return; //The number of functions to return.
}
}
/*---------功能(删除1位密码)-----------*/
if(key_16mun == 15 && in_password_mun != 255)
{
if(intput == 1) //如果是第1次输入新密码.
{
password1[in_password_mun] = 20;
write_com(0X87 + in_password_mun); //液晶AC控制到第2行的第7位置.
write_date(' ');
write_com(0X87 + in_password_mun); //液晶AC控制到第2行的第7位置.
}
else
{
password2[in_password_mun] = 20;
write_com(0XC7 + in_password_mun); //液晶AC控制到第2行的第7位置.
write_date(' ');
write_com(0XC7 + in_password_mun); //液晶AC控制到第2行的第7位置.
}
if(in_password_mun > 0)
in_password_mun--;
else
in_password_mun = 255; //Record password input digits to restore.
}
/*---------功能(显示输入密码)-----------*/
if(key_16mun == 14)
{
password_dis = !password_dis;
write_com(0Xc7); //液晶AC控制到第2行的第7位置.
for(i = 0;i < 6;i++) //循环检查6位密码,and displayed on the screen
{
if(password2[i] != 20) //If not the original value,Indicates that there is a new password
{
if(password_dis == 0)
write_date('*'); //Enter the password with *号显示出来.
else
write_date(muntochar[password2[i]]);
}
}
//主要目的为 * Toggle display with physical password,The password value entered for the first time is taken into account----------------------------
write_com(0X87); //液晶AC控制到第1行的第7位置.
for(i = 0;i < 6;i++) //循环检查6位密码,and displayed on the screen
{
if(password1[i] != 20) //If not the original value,Indicates that there is a new password
{
if(password_dis == 0)
write_date('*'); //Enter the password with *号显示出来.
else
write_date(muntochar[password1[i]]);
}
}
//------------------------------------------------------------
}
/*-------Exit without operation------*/
if(flag_200ms == 1)
{
flag_200ms = 0; //200mSThe flag is set to clear0
out_time++;
if(out_time == 5 * 10) //10秒时间.
{
/*----The LCD returns to the standby state display----*/
write_string(1,0," Password Lock "); //LCD display characters
write_string(2,0," Input: "); //LCD display characters
write_com(0XC7); //液晶AC控制到第2行的第7位置.
Beep = 0; //Beep prompt.
delay_ms(250);
Beep = 1;
return ; //函数返回
}
}
}
}
边栏推荐
- 使用设备树时对应的驱动编程
- opencv语法Mat类型总结
- 一加OnePlus 10RT出现在Geekbench上 产品发布似乎也已临近
- 【R语言】批量重命名文件
- 自定义注解实现日志打印时屏蔽特定字段不打印
- 金仓数据库KingbaseES安全指南--6.4. RADIUS身份验证
- 史上最全的Redis基础+进阶项目实战总结笔记
- 统信软件、龙芯中科等四家企业共同发布《数字办公安全创新方案》
- GridControl helper class for DevExpress
- [Dark Horse Morning Post] Hu Jun's endorsement of Wukong's financial management is suspected of fraud, which is suspected to involve 39 billion yuan; Fuling mustard responded that mustard ate toenails
猜你喜欢
存储日报-数据湖架构权威指南(使用 Iceberg 和 MinIO)
M1芯片电脑安装cerebro
千万级乘客排队系统重构&压测方案总结篇
Description of common operations and help projects about DevExpress in C#
金仓数据库 KingbaseES V8.3 至 V8.6 迁移最佳实践(4. V8.3 到 V8.6 数据库移植实战)
成为优秀架构师必备技能:怎样才能画出让所有人赞不绝口的系统架构图?秘诀是什么?快来打开这篇文章看看吧!...
QT常用全局宏定义
How can become a good architect necessary skills: painting for all the people praise the system architecture diagram?What is the secret?Quick to open this article and have a look!.
05 Doris cluster construction
不需要写代码,快速批量修改文件夹中图片的格式
随机推荐
银行案例|Zabbix跨版本升级指南,4.2-6.0不香吗?
The anxiety of the post-90s was cured by the vegetable market
SQL函数 TO_CHAR(三)
频域分析实践介绍
SQL函数 TO_CHAR(二)
百度网盘下载速度提升100倍
下载 | 谷歌科学家Kevin P. Murphy发布新书《概率机器学习:高级主题》
【R语言】批量重命名文件
zabbix部署和简单使用
中信证券是国内十大券商吗?怎么开户安全?
基于BiGRU和GAN的数据生成方法
关于Mysql服务无法启动的问题
食品安全 | 新鲜食品vs速食食品,哪一种是你的菜?
SQL函数 TO_CHAR(一)
存储日报-数据湖架构权威指南(使用 Iceberg 和 MinIO)
QT_事件类
MySQL 45 讲 | 09 普通索引和唯一索引,应该怎么选择?
opencv实时人脸检测
想做期货,农产品期货怎么炒?波动大么
The site is not found after the website is filed. You have not bound this domain name or IP to the corresponding site! The configuration file does not take effect!