确认按下数字
#include <REGX52.H>
#include "Delay.h"
#include "LCD1602.h"
#include "matrixkey.h"
unsigned char key;
unsigned int Password=0,count;
void main()
{
LCD_Init();
LCD_ShowString(1,1,"Password:");
while(1)
{
key=matrixkey();
if(key!=0)
{
if(key<=10)
{
if(count<4)
{
Password*=10;
Password+=key%10;
count++;
}
LCD_ShowNum(2,1,Password,4);
}
确认密码
if(key==11)
{
if(Password==5678)
{
LCD_ShowString(2,14,"OKK");
Password=0;
count=0;
LCD_ShowNum(2,1,Password,4);
}
else
{
LCD_ShowString(2,14,"EFF");
Password=0;
count=0;
LCD_ShowNum(2,1,Password,4);
}
}
取消重新输入
if(key==12)
{
Password=0;
count=0;
LCD_ShowNum(2,1,Password,4);
}