這個(gè)程序真的花了我好長(zhǎng)的時(shí)間調(diào)試,終于寫(xiě)好了,大家可以看看我的密碼鎖,有點(diǎn)花哨嘔?。?/p>
下面是密碼鎖簡(jiǎn)約版本:
main.c
#include
#include"12864.h"
#include"keyscan.h"
#include"baojin.h"
uchar mima[5]={1,2,3,4,5};
main()
{
uchar length,i,flag,inputtimes,flagkaimeng;//tempê??ü??μ?áùê±±?á?
uchar itouch,flaggaimima;//ó?à′???????yê?è?μ??ü??μ???êy
uchar mimatemp[5];
init_12864();
lcd_pos(0,2);
write_string("welcom!!");
delay1ms(2);
lcd_pos(1,0);
write_string("PSW:");
write_cmd(0x0f);//′ò?a1a±ê
f3:
while(1)
{
i=0;
if(inputtimes>=1)//ê?è?′í?óoóμ??¢μ÷?êìa
{
lcd_pos(1,2);
write_string(" ");
lcd_pos(1,2);
}
while(1)
{
f:
num=keyscan();
if(num!=0xff)
{
if(num==15)//?¨ò??aè·è?
break;
if(num==16)//?a????·¨?éò?êμ???à2?í???
{
i--;//±íê??°??ê?è?μ?êy?Y?TD§
lcd_pos(1,2);
write_string(" ");
lcd_pos(1,2);
if(i==-1)//±ü?a?à′?°′???ì3ébug
i=0;
for(itouch=0;itouch
write_string("*");
goto f;
}
if(num==14)//±íê?òaDT???ü??
{
flaggaimima = 1;
break;
}
if(num!=16)//16?¨ò??a??3μ£???3y?°??ò???êy?Y
{
mimatemp[i]=num;
i++;
length = i;
write_string("*");
//write_date(num+0x30);
}
}
}
if(flaggaimima==1)
{
flaggaimima = 0;
while(1)
{
f1:
num=keyscan();
if(num!=0xff)
{
if(num==15)//?¨ò??aè·è?±íê?DT???ü???áê?
{
lcd_pos(1,2);
write_string(" ");
lcd_pos(1,2);
break;
}
if(num==16)//?a????·¨?éò?êμ???à2?í???
{
i--;//±íê??°??ê?è?μ?êy?Y?TD§
lcd_pos(1,2);
write_string(" ");
lcd_pos(1,2);
if(i==-1)//±ü?a?à′?°′???ì3ébug
i=0;
for(itouch=0;itouch
write_string("*");
goto f1;
}