#include<REGX52.H>
#include"Delay.h"
#include"Key.h"
#include"LCD1602.h"
unsigned char keynum;
unsigned int passward=0,count=0;
void main()
{
LCD_Init();
LCD_ShowString(1,1,"passward:");
while(1)
{
keynum=Key();
if(keynum)
{
if(keynum<=10)
{
if(count<4)
{
passward=passward*10+keynum%10;
count++;
}
}
LCD_ShowNum(2,1,passward,4);
if(keynum==11)
{
if(passward==1210)
{
LCD_ShowString(1,10,"trun");
}
else
{
LCD_ShowString(1,10,"error");
}
}
if(keynum==12)
{
passward=0;
count=0;
LCD_ShowNum(2,1,passward,4);
}
}
}
}
头文件在上一篇