电子密码锁双按键51程序Word下载.docx
《电子密码锁双按键51程序Word下载.docx》由会员分享,可在线阅读,更多相关《电子密码锁双按键51程序Word下载.docx(14页珍藏版)》请在冰豆网上搜索。
//16
ucharcodetables[]="
changesuccess"
ucharcodexing[]="
*"
sbitk0=P3^0;
sbitk1=P3^1;
sbitlcden=P2^6;
sbitlcdrs=P2^4;
sbitlcdrw=P2^5;
sbitdeng=P1^0;
sbitjin=P2^0;
voiddelay(uintz)
{
uintx,y;
for(x=z;
x>
0;
x--)
for(y=110;
y>
y--);
}
voidwrite_com(ucharcom)
lcdrs=0;
lcdrw=0;
P0=com;
delay(5);
lcden=1;
lcden=0;
voidwrite_date(uchardate)
lcdrs=1;
P0=date;
ucharkeyscan()
if(k0==0)
{
delay(5);
if(k0==0)
num=1;
while(!
k0);
}
if(k1==0)
if(k1==0)
num=2;
k1);
}
returnnum;
voidinit()
TMOD=0x01;
TH0=(65536-1000)/256;
TL0=(65536-1000)%256;
EA=1;
ET0=1;
write_com(0x38);
write_com(0x0f);
write_com(0x06);
write_com(0x01);
a=1;
b=2;
c=3;
d=4;
e=5;
f=6;
voidinput()
write_com(0x80);
for(i=0;
i<
10;
i++)
write_date(tableshu[i]);
delay
(1);
while
(1)
keyscan());
if(num==1)
{
num=0;
j++;
if(j==10)
j=0;
write_com(0x80+j);
}
else
{
write_com(0x80+0x40+k);
write_date(xing[0]);
write_com(0x80);
k++;
if(k==1&
&
j==a)
flag++;
if(k==2&
j==b)
if(k==3&
j==c)
if(k==4&
j==d)
if(k==5&
j==e)
if(k==6&
j==f)
if(k==6)
k=0;
break;
if(flag==6)
flag=0;
write_com(0x01);
write_com(0x0c);
for(i=0;
5;
write_date(tableright[i]);
delay
(1);
deng=0;
else
write_date(tablewrong[i]);
}
cnt++;
if(cnt==3)
cnt=0;
TR0=1;
while
(1)
{
if(shu==10000)
{
shu=0;
break;
}
}
voidchange()
write_com(0x80+0x40);
11;
write_date(tableold[i]);
if(flag!
=6)
flag1=1;
write_com(0x80+0x40);
write_date(tablenew[i]);
write_com(0x80);
while
(1)
while(!
if(num==1)
else
num=0;
write_com(0x80+0x40+k);
write_date(xing[0]);
write_com(0x80);
k++;
if(k==1)
aa=j;
if(k==2)
bb=j;
if(k==3)
cc=j;
if(k==4)
dd=j;
if(k==5)
ee=j;
if(k==6)
ff=j;
j=0;
if(k==6)
k=0;
break;
16;
write_date(tablena[i]);
write_com(0x81+j);
j++;
if(j==9)
if(k==1&
j==aa)
flag2++;
if(k==2&
j==bb)
if(k==3&
j==cc)
if(k==4&
j==dd)
if(k==5&
j==ee)
if(k==6&
j==ff)
if(flag2==6)
flag2=0;
a=aa;
b=bb;
c=cc;
d=dd;
e=ee;
f=ff;
write_com(0x01);
write_com(0x0c);
for(i=0;
14;
write_date(tables[i]);
delay
(1);
flag1=2;
flag1=1;
voidmain()
init();
write_com(0x0f);
12;
write_date(table[i]);
write_com(0x80+5);
input();
delay(1000);
if(deng==0)
change();
if(flag1==1)
flag1=0;
write_com(0x01);
for(i=0;
write_date(tablewrong[i]);
delay
(1);
voidtimer0()interrupt1
shu++;
if(shu==10000)
TR0=0;
jin=~jin;