|
采用指紋識(shí)別和密碼識(shí)別雙重保證。是用51單片機(jī)編寫(xiě)的源程序
電路原理圖如下:
51hei.png (40.46 KB, 下載次數(shù): 50)
下載附件
2022-3-28 05:00 上傳
Altium Designer畫(huà)的單片機(jī)指紋考勤機(jī)PCB圖如下:(51hei附件中可下載工程文件)
PCB.png (21.52 KB, 下載次數(shù): 56)
下載附件
2022-3-28 05:01 上傳
51hei.png (16.23 KB, 下載次數(shù): 45)
下載附件
2022-3-28 05:01 上傳
元件清單
1) 9*15萬(wàn)用板
2) 指紋傳感器
3) 40腳座
4) 單片機(jī)
5) 12864有字庫(kù)液晶
6) 20p插針
7) 20p單排母座
8) 按鍵*17
9) 103電位器(藍(lán)白)
10) 1k電阻*3
11) 10k電阻*1
12) 10uf電容
13) 30pf電容*2
14) 11.0592m晶振
15) AMS1117
16) 100Uf*2
17) 自鎖開(kāi)關(guān)
18) DC電源接口
19) 導(dǎo)線若干
20) 焊錫若干
21) usb電源線
單片機(jī)源程序如下:
- #include"reg52.h"
- #include"12864.h"
- #include"eeprom.h"
- #include"matrixkey.h"
- #include"AT24CXX.h"
- #include"finger.h"
- uchar code table1[]="A:簽到 B:添加 ";
- uchar code table2[]="C:清空 D:上課 ";
- uchar code table3[]=" *查詢?nèi)鼻谌藛T ";
- uchar code table4[]=" #查詢遲到人員 ";
- uchar code table5[]="請(qǐng)輸入刪去密碼: ";
- uchar code table6[]=" 開(kāi)始簽到 ";
- uchar code table7[]=" 請(qǐng)按指紋簽到 ";
- uchar code table8[]=" ";
- uchar code table9[]="按D: 開(kāi)始上課 ";
- uchar code table10[]="請(qǐng)輸入密碼: ";
- uchar code table11[]=" 簽到成功 ";
- uchar code table12[]="請(qǐng)按任意按鍵繼續(xù)";
- uchar code table13[]=" 編號(hào)為: ";
- uchar code table14[]=" 請(qǐng)按手指 ";
- uchar code table15[]=" 請(qǐng)?jiān)侔匆淮?nbsp; ";
- uchar code table16[]=" 采集指紋成功 ";
- uchar code table17[]="輸入刪去的指紋號(hào)";
- uchar code table18[]="刪去指紋庫(kù)成功 ";
- uchar code table19[]="刪去指紋庫(kù)失敗 ";
- uchar code table20[]=" 請(qǐng)輸入新密碼 ";
- uchar code table21[]="請(qǐng)?jiān)俅屋斎胄旅艽a";
- uchar code table22[]=" 密碼修改成功 ";
- uchar code table23[]=" 兩次密碼不一樣";
- uchar code table24[]=" 輸入密碼錯(cuò)誤 ";
- uchar code table25[]=" 還有 機(jī)會(huì) ";
- uchar code table26[]=" 該指紋已存儲(chǔ) ";
- uchar code table27[]=" 采集指紋失敗 ";
- uchar code table28[]="確定刪去指紋庫(kù)?";
- uchar code table29[]="按D: 本節(jié)課結(jié)束";
- uchar code table30[]="當(dāng)前缺勤 人";
- uchar code table31[]="當(dāng)前遲到 人";
- uchar code digital[15]={0x90,0x92,0x94,0x96,0x88,0x8a,0x8c,0x8e,0x98,0x9a,0x9c,0x9e};
- uchar xdata table_qiandao[100];
- uchar queqing=0;//缺勤人數(shù)
- uchar zz;
- uchar chidao=0;//遲到人數(shù)
- uchar code admin[6]={1,3,1,4,2,0};//管理員的固定密碼
- uchar code init_code[6]={0,0,0,0,0,0};//上電第一次一般的初始化密碼
- uchar now_code[6]={0,0,0,0,0,0};//當(dāng)前存儲(chǔ)器中存儲(chǔ)的密碼
- uchar user[6]={0,0,0,0,0,0};//用戶輸入的密碼
- uchar user2[6]={0,0,0,0,0,0};//輸入第二次修改的密碼
- sbit relay=P3^7;//開(kāi)鎖繼電器
- sbit wake=P3^6;//檢測(cè)手指按壓,有手指按下就是高電平
- uchar jishu=0;
- uchar err_user=3;//用戶三次輸入錯(cuò)誤密碼
- uchar err_admin=3;//管理員三次輸入錯(cuò)誤密碼
- uchar num;//存儲(chǔ)矩陣鍵盤(pán)轉(zhuǎn)換的對(duì)應(yīng)按鍵值
- uchar number=0;//輸入密碼的個(gè)數(shù)默認(rèn)0
- uchar key_flag=0;//進(jìn)入手動(dòng)密碼標(biāo)志
- uchar i;
- uchar code_flag=0;//密碼修改標(biāo)志第一次輸入密碼時(shí)候是等于0再次輸入是等于1
- void init_dispay(void)//初始化界面
- {
- PutStr(0,0,table1);
- PutStr(1,0,table2);
- PutStr(2,0,table3);
- PutStr(3,0,table4);
- }
- void admin_dispay(void)//管理員界面
- {
- PutStr(0,0,table6);
- PutStr(1,0,table7);
- PutStr(2,0,table8);
- PutStr(3,0,table9);
- }
- void init_shuju(void)
- {
- uchar i;
- for(i=0;i<100;i++)
- {
- table_qiandao[i]=0x00;
- }
- }
- void que_renshu(void)
- { queqing=0;//缺勤人數(shù)
- // WriteCommand(0x80+2);
- // WriteData(jishu/10+0x30);
- // WriteData(jishu%10+0x30);
- for(i=0;i<jishu;i++)
- {
- if(table_qiandao[i]==0x00)
- {
- queqing++;
- WriteCommand(digital[queqing-1]);
- WriteData((i+1)/10+0x30);
- WriteData((i+1)%10+0x30);
-
- }
- }
- }
- void chidao_renshu(void)
- { queqing=0;//缺勤人數(shù)
- // WriteCommand(0x80+2);
- // WriteData(jishu/10+0x30);
- // WriteData(jishu%10+0x30);
- for(i=0;i<jishu;i++)
- {
- if(table_qiandao[i]>=2)
- {
- queqing++;
- WriteCommand(digital[queqing-1]);
- WriteData((i+1)/10+0x30);
- WriteData((i+1)%10+0x30);
-
- }
- }
- }
- void key(void)
- {
- num=keynum();
- if((num==12)&&(key_flag==0))//查看缺勤人數(shù)
- {
- LcmClearTXT();//清屏
- PutStr(0,0,table30);
- que_renshu();
- WriteCommand(0x80+6);
- WriteData(queqing/10+0x30);
- WriteData(queqing%10+0x30);
- while((keynum()>=16));
- init_dispay();
- }
- if((num==14)&&(key_flag==0))//查看遲到人數(shù)
- {
- LcmClearTXT();//清屏
- PutStr(0,0,table31);
- chidao_renshu();
- WriteCommand(0x80+6);
- WriteData(queqing/10+0x30);
- WriteData(queqing%10+0x30);
- while((keynum()>=16));
- init_dispay();
- }
- if((num==11)&&(key_flag==0))//如果按下C按鍵進(jìn)
- {
- key_flag=1;
- //只顯示“請(qǐng)輸入密碼開(kāi)鎖:“
- LcmClearTXT();//清屏
- PutStr(0,0,table28);
- PutStr(1,0,table5);
- }
- if((num==7)&&(key_flag==0))//如果按下B按鍵進(jìn)入添加指紋
- {
-
- LcmClearTXT();//清屏
- PutStr(1,0,table14); //顯示請(qǐng)按指紋
- if(regist(0)==1)//如果第一次按手指成功
- {
- PutStr(1,0,table15); //顯示請(qǐng)?jiān)侔匆淮?br />
- Delay(10);//延時(shí)一會(huì)
- if(regist(1)==1)//兩次采集手指成功
- {
- PutStr(1,0,table16); //采集指紋成功
- PutStr(2,0,table13); //指紋編號(hào):
- WriteCommand(0x88+5);//指定第三行顯示位置
- WriteData(' ');
- id=id+1;
- WriteData(id/100+0x30);
- WriteData(id%100/10+0x30);
- WriteData(id%10+0x30);
- SectorErase(0x2200);
- jishu=id%256;
- byte_write(0x2200, id%256);
-
- }
- else PutStr(1,0,table27); //采集指紋失敗
- }
- else if(regist(0)==2)//已經(jīng)注冊(cè)過(guò)指紋
- {
- PutStr(1,0,table26); //指紋已經(jīng)存儲(chǔ)
- }
-
- PutStr(3,0,table12); //請(qǐng)按任意鍵退出
- while(keynum()>=16);
- init_dispay();//管理員設(shè)置界面
- key_flag=0;
- num=0xff;
- }
- if((num==3)&&(key_flag==0))//如果按下A按鍵管理員模式
- {
- key_flag=2;//進(jìn)入輸入管理員密碼界面
- //只顯示“請(qǐng)輸入密碼:“
- LcmClearTXT();//清屏
- PutStr(1,0,table10);
- }
- if((key_flag==1)&&(num!=0xff))//非管理員模式下輸入密碼
- {
- num=coding(num);//轉(zhuǎn)換成可以識(shí)別的
- if((number<6)&&(num<10))
- {
- user[number]=num;//用戶輸入的密碼進(jìn)行記憶
- WriteCommand(0x88+number); //指定第三行顯示位置
- WriteData('*');
- //WriteData(num+0x30);//明碼顯示
- number++;
- }
- if((num=='B')&&(number>0))//密碼刪除按鍵
- { number--;
- WriteCommand(0x88+number); //指定第三行顯示位置
- WriteData(' ');
- }
- if(number==6)//按下D鍵確定按鍵并且輸入六位密碼之后
- {
- LcmClearTXT();//清屏
- number=0;
- key_flag=0;
- //如果管理員密碼正確,進(jìn)入添加指紋,刪除指紋,收到開(kāi)鎖,修改密碼界面
- if((user[0]==now_code[0])&&(user[1]==now_code[1])&&(user[2]==now_code[2])&&(user[3]==now_code[3])&&(user[4]==now_code[4])&&(user[5]==now_code[5]))
- {
- if(cancel(0x63)==1)
- {
- PutStr(0,0,table18);//輸入刪去的指紋號(hào)成功
- SectorErase(0x2200);
- byte_write(0x2200, 0x00);
- }
- else
- {
- PutStr(0,0,table19);//輸入刪去的指紋號(hào)失敗
- }
- Delay(80);
- }
- else//密碼錯(cuò)誤
- {
- PutStr(1,0,table24);//顯示輸入密碼錯(cuò)誤
-
-
- }
- PutStr(3,0,table12);
- while((keynum()>=16)&&(err_user!=0));
- init_dispay();//初始化界面
- }
-
- }
- if((key_flag==2)&&(num!=0xff))//簽到模式下輸入數(shù)字按鍵
- {
- num=coding(num);//轉(zhuǎn)換成可以識(shí)別的
- if((number<6)&&(num<10))
- {
- user[number]=num;//用戶輸入的密碼進(jìn)行記憶
- WriteCommand(0x88+number); //指定第三行顯示位置
- WriteData('*');
- // WriteData(num+0x30); //明碼顯示
- number++;
- }
- if(number==6)//輸入六位以后進(jìn)行密碼校驗(yàn)
- { //如果管理員密碼正確,進(jìn)入添加指紋,刪除指紋,收到開(kāi)鎖,修改密碼界面
- if((user[0]==admin[0])&&(user[1]==admin[1])&&(user[2]==admin[2])&&(user[3]==admin[3])&&(user[4]==admin[4])&&(user[5]==admin[5]))
- {
- key_flag=55;
- admin_dispay();//進(jìn)入簽到頁(yè)面
- err_admin=3;
- num=0XFF;
- init_shuju();
- }
- else//管理員密碼錯(cuò)誤
- {
-
- PutStr(1,0,table24);//顯示輸入密碼錯(cuò)誤
- PutStr(3,0,table12);
- while((keynum()>=16)&&(err_admin!=0));
- init_dispay();//初始化界面
- number=0;
- key_flag=0;
- }
- }
- if((num=='B')&&(number>0))
- {
- number--;
- WriteCommand(0x88+number); //指定第三行顯示位置
- WriteData(' ');
- }
-
-
- }
- if(key_flag==55)//進(jìn)入簽到指紋巡查
- { num=coding(num);//轉(zhuǎn)換成可以識(shí)別的
- if(num=='D')//按下就進(jìn)入開(kāi)始上課
- {
- key_flag=56;
- PutStr(3,0,table29);
- }
- if(wake==1)//如果有手指按下
- {
- if(check()==1)//進(jìn)行指紋匹配
- { err_admin=3;
- err_user=3;
- LcmClearTXT();//清屏
- PutStr(1,0,table11);
- PutStr(2,0,table13);
- WriteCommand(0x88+5); //指定第三行顯示位置
- WriteData(' ');
- zz=id%256;
- table_qiandao[zz]=0x01;
- id++;
- WriteData(id/100+0x30);
- WriteData(id%100/10+0x30);
- WriteData(id%10+0x30);
-
- // WriteData(table_qiandao[zz]%100/10+0x30);
- // WriteData(table_qiandao[zz]%10+0x30);
- relay=0;
- Delay(80);
- relay=1;
- Delay(20);
- PutStr(3,0,table12);
- number=0;
- key_flag=55;
- admin_dispay();//回到初始界面
- num=0xff;
-
- }
- }
- }
- if(key_flag==56)//遲到的
- { num=coding(num);//轉(zhuǎn)換成可以識(shí)別的
- if(num=='D')//按下就進(jìn)入開(kāi)始上課
- {
- key_flag=0;
- number=0;
- init_dispay();
- }
- if(wake==1)//如果有手指按下
- {
- if(check()==1)//進(jìn)行指紋匹配
- {
- LcmClearTXT();//清屏
- PutStr(1,0,table11);
- PutStr(2,0,table13);
- WriteCommand(0x88+5); //指定第三行顯示位置
- WriteData(' ');
- zz=id%256;
- table_qiandao[zz]=table_qiandao[zz]+0x02;
- id++;
- WriteData(id/100+0x30);
- WriteData(id%100/10+0x30);
- WriteData(id%10+0x30);
-
- // WriteData(table_qiandao[zz]%100/10+0x30);
- // WriteData(table_qiandao[zz]%10+0x30);
- relay=0;
- Delay(80);
- relay=1;
- Delay(20);
- PutStr(3,0,table12);
- number=0;
- key_flag=56;
- admin_dispay();//回到初始界面
- PutStr(3,0,table29);
- num=0xff;
- }
- }
- }
-
- }
- void main()
- {
- for(i=0;i<6;i++)//讀取存儲(chǔ)器中的密碼
- {
- now_code[i]=read_add(20+i);
- Delay(5);
- }
- for(i=0;i<6;i++)
- {
- if(now_code[i]>9)
- {
- i=10;
- break;
- }
- }
- if(i>9)//設(shè)置初始化密碼
-
- {
- for(i=0;i<6;i++)
- {
- now_code[i]=init_code[i];
- Delay(5);
- }
- }
-
- LcmInit();//初始化12864
-
-
-
- jishu=byte_read(0x2200);
- // WriteCommand(0x88);
- // WriteData(jishu/10+0x30);
- // WriteData(jishu%10+0x30);
- // Delay(30);
- // Delay(50);
- init_dispay();//進(jìn)入初始化顯示界面
- UART_Init(); //初始化串口9600
- init_shuju();
- while(1)
- {
- key();
- }
- }
復(fù)制代碼
51hei.png (5.57 KB, 下載次數(shù): 47)
下載附件
2022-3-28 05:01 上傳
所有資料51hei附件下載:
指紋考勤.7z
(1.51 MB, 下載次數(shù): 87)
2022-3-28 05:02 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
評(píng)分
-
查看全部評(píng)分
|