电子密码锁的设计 第4页
bit alarmflag;
bit exchangeflag;
unsigned int cc;
unsigned int dd;
bit okflag;
unsigned char oka;
unsigned char okb;
void main(void)
{
unsigned char i,j;
P2=dispcode[digitcount];
TMOD=0x01;
TH0=(65536-500)/256;
TL0=(65536-500)%6;
TR0=1;
ET0=1;
EA=1;
while(1)
{
if(cmpflag==0)
{
if(P3_6==0)
{
for(i=10;i>0;i--)
for(j=248;j>0;j--);
if(P3_6==0)
{
if(hibitflag==0)
{
funcount++;
if(funcount==pslen+2)
{
funcount=0;
cmpflag=1;
}
P1=dispcode[funcount];
}
else
{
second3=0;
}
while(P3_6==0);
}
}
if(P3_7==0)
{
for(i=10;i>0;i--)
for(j=248;j>0;j--);
if(P3_7==0)
{
if(hibitflag==0)
{
digitcount++;
if(digitcount==10)
{
digitcount=0;
}
P2=dispcode[digitcount];
if(funcount==1)
{
pslen=digitcount;
templen=pslen;
}
else if(funcount>1)
{
psbuf[funcount-2]=digitcount;
}
}
else
{
second3=0;
}
while(P3_7==0);
}
}
}
else
{
cmpflag=0;
for(i=0;i
{
if(ps[i]!=psbuf[i])
{
hibitflag=1;
www.751com.cn
cmpflag=0;
second3=0;
goto a;
}
}
cc=0;
errorflag=0;
rightflag=1;
hibitflag=0;
a: cmpflag=0;
}
}
}
void t0(void) interrupt 1 using 0
{
TH0=(65536-500)/256;
TL0=(65536-500)%6;
if((errorflag==1) && (rightflag==0))
{
bb++;
if(bb==800)
{
bb=0;
alarmflag=~alarmflag;
}
if(alarmflag==1)
{
P0_0=~P0_0;
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页