红外遥控密码锁讲解 下载本文

if((key2[0]==key1[0])&&(key2[1]==key1[1])&&(key2[2]==key1[2])&&(key2[3]==key1[3])&&(key2[4]==key1[4])&&(key2[5]==key1[5])&&(key2[6]==key1[6])&&(key2[7]==key1[7])) {uint h; g=1;

for(h=0;h<10;h++) {P0_2=0; delay(30); P0_2=1; delay(30); } for(h=0;h<8;h++) {key1[h]=0;} i=0; rag=0; }

//修改密码,输入新密码 if(G)

{if(rag) { uint B;

key[b]=disp[4]; key[b+1]=disp[5]; b=b+2; if(b==8) {b=0; G=0;

RFLAG=1; alarm=0;

for(B=0;B<8;B++) {key1[B]=0; }

for(B=0;B<10;B++) {P0_1=0; delay(20); P0_1=1; delay(20); } i=0; } rag=0; } } if(g)

{ if(rag)

16

{uint D;

key2[d]=disp[4]; key2[d+1]=disp[5]; d=d+2; if(d==8) {d=0; g=0;

RFLAG=1; alarm=0;

for(D=0;D<8;D++) {key1[D]=0; }

for(D=0;D<10;D++) {P0_2=0; delay(20); P0_2=1; delay(20); } i=0; } rag=0; } } }

//红外控制电控锁旋转 if(RFLAG) {

if((key[0]==key1[0])&&(key[1]==key1[1])&&(key[2]==key1[2])&&(key[3]==key1[3])&&(key[4]==key1[4])&&(key[5]==key1[5])&&(key[6]==key1[6])&&(key[7]==key1[7]))

{uint j=128; if(FLAG) {P0_1=0; while(j--)

{for(k=0;k<4;k++) {P2=table1[k]; delay1(800); }

17

} P0_1=1; FLAG=0; rflag=1; alarm=0; i=0; } }

if((key2[0]==key1[0])&&(key2[1]==key1[1])&&(key2[2]==key1[2])&&(key2[3]==key1[3])&&(key2[4]==key1[4])&&(key2[5]==key1[5])&&(key2[6]==key1[6])&&(key2[7]==key1[7])) { uint j=128; if(rflag) {P0_2=0; while(j--)

{for(k=0;k<4;k++) {P2=table2[k]; delay1(800); } }

P0_2=1; rflag=0; FLAG=1; alarm=0; i=0; } }

if((disp[4]==0)&&(disp[5]==9)) {if(FLAG) {uchar n; for(n=0;n<10;n++) {P0_1=0; delay(20); P0_1=1; delay(20); } }

if(rflag) {uchar m; for(m=0;m<10;m++) {P0_2=0; delay(20); P0_2=1;

18

delay(20); } } disp[4]=0; disp[5]=0; i=0; }

if(alarm>5) {uint f=20; while(f--) {BEEP();} i=0;

alarm=0; } } } }

void time0() interrupt 1 {htime++; }

void int1() interrupt 2 {

if(startflag) {

if(htime>35)

bytenumber=0;

hdata[bytenumber]=htime; htime=0;

bytenumber++; if(bytenumber==33) {bytenumber=0; endflag=1; } }

else {

startflag=1; htime=0; } }

19