《指纹密码锁主程序》由会员分享,可在线阅读,更多相关《指纹密码锁主程序(26页珍藏版)》请在金锄头文库上搜索。
1、-*include *include *include24C0*.h*includeLCD12864.h*define uchar unsigned char*define uint unsigned int*define buffer1ID 0*01*define buffer2ID 0*02*define queren 0*88*define tuichu 0*84*define shanchu 0*82*define User 2 void fan();sbit B0=B0;sbit B7=B7;sbit k2=P37;sbit jidianqi=P36;/sbit Buzzer=P00
2、;e*tern unsigned char times;uchar Member,sec,z=0; / =1uchar code bufferUser6= 000000;uchar dz4;uchar time4; uchar mima6;uchar mimag6;/uchar mimaID6=1,2,3,4,5,6;uchar mimaID6;uchar data K;uchar data Key;uint PageID;uchar data querenma=11;uchar sum2;int summaf,summas;uchar *data UserPassword6=0;/密码uch
3、ar *data DSY_BUFFER16 =0;/缓存void Red_Init(void);/检测脉冲宽度unsigned char check(void);unsigned char redchange(unsigned char rednum);void delayms(unsigned int z)unsigned int *,y;for(*=z;*0;*-)for(y=110;y0;y-);/* 名称 : Chack(uchar User_Number)* 功能 : 单一用户密码检测* 输入 : User_Number* 输出 : 密码正确与错误,错误返回0,正确返回1*/ucha
4、r Chack(uchar User_Number)uchar flag, i,temp6,Address;Address=User_Number*10;for(i=0;i6;i+)tempi=*24c02_read(Address);delayms(10);Address+;for(i=0;i6;i+)if(tempi=UserPasswordi)flag=1;else flag=0;return flag;/* 名称 : PassWord_Chack()* 功能 : 所有用户密码检测* 输入 : 无* 输出 : 密码正确与错误,错误返回0,正确返回1*/uchar PassWord_Cha
5、ck()uchar i=0;while(iUser)if(Chack(i)=1)Member=i+1;return 1;i+;return 0;void delay(uint tt) uchar i; while(tt-) for(i=0;i125;i+); /* 名称 : UART_Init()* 功能 : 单片机串口初始化* 单片机:晶振11.0592MHz 波特率为9600bps* 指纹模块:波特率为9600bps,*/ void UART_Init()SCON= 0*50; /串口方式1/REN=1; 允许接收PCON=0*00; /SMOD=0TMOD= 0*21; /定时器1定时方
6、式2TH1= 0*FD; /11.0592MHz 模块默认波特率为9600bpsTL1= 0*FD; TR1= 1; /启动定时器 EA=1; unsigned char Keycan(void) /按键扫描程序 P1.0-P1.3为行线 P1.4-P1.7为列线 unsigned char rcode, ccode; P1 = 0*F0; / 发全0行扫描码,列线输入 if(P1&0*F0) != 0*F0) / 假设有键按下 delay(1);/ 延时去抖动 if(P1&0*F0) != 0*F0) rcode = 0*FE; / 逐行扫描初值 while(rcode&0*10) != 0
7、) P1 = rcode; / 输出行扫描码 if(P1&0*F0) != 0*F0) / 本行有键按下 ccode = (P1&0*F0)|0*0F; /do; while(P1&0*F0) != 0*F0); /等待键释放 return (rcode) + (ccode); / 返回键编码 else rcode = (rcode1)|0*01; / 行扫描码左移一位 return 0; / 无键按下,返回值为0void KeyDeal(unsigned char Key) /unsigned char n; if(Key!=0) switch(Key) case 0*11: K=1; br
8、eak; case 0*21: K=2; break; case 0*41: K=3; break; case 0*81: break; case 0*12: K=4; break; case 0*22: K=5; break; case 0*42: K=6; break; case 0*82: K=34;break; case 0*14: K=7; break; case 0*24: K=8; break; case 0*44: K=9; break; case 0*84: break; case 0*18: break; case 0*28: K=0; break; case 0*48:
9、K=11; break; case 0*88: break; default: break; /*/void SFG_getimage() /录入指纹图像 uchar i; SBUF=0*ef; while(TI=0); TI=0; SBUF=0*01; while(TI=0); TI=0; SBUF=0*FF; while(TI=0); TI=0; SBUF=0*FF; while(TI=0); TI=0; SBUF=0*FF; while(TI=0); TI=0; SBUF=0*FF; while(TI=0); TI=0; SBUF=0*01; while(TI=0); TI=0; SBU
10、F=0*00; while(TI=0); TI=0; SBUF=0*03; while(TI=0); TI=0; SBUF=0*01; while(TI=0); TI=0; SBUF=0*00; while(TI=0); TI=0; summaf=0*05; SBUF=summaf; while(TI=0); TI=0; for(i=0;i9;i+) while(RI=0); RI=0; while(RI=0); RI=0; querenma=SBUF; while(RI=0); RI=0; sum1=SBUF; while(RI=0); RI=0; sum0=SBUF; summas=(sum18)+sum0; void SFG_genchar(uchar bufferID) /生成特征并存于charbuffer1/2 调用后单片机波特率变化 uchar i; SBUF=0*ef; while(TI=0); TI=0; SBUF=0*01; while(TI=0); TI=0; SBUF=0*FF; while(TI=0); TI=0; SBUF=0*FF; while(TI=0); TI=0; SBUF=0*FF; while(TI=0); TI=0; SBUF=0*FF; while(TI=0); TI=0; SBUF=0*01; while(