找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 3279|回復(fù): 1
打印 上一主題 下一主題
收起左側(cè)

基于51單片機(jī)的智能門(mén)禁指紋考勤系統(tǒng)設(shè)計(jì) 原理圖PCB源程序

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
采用指紋識(shí)別和密碼識(shí)別雙重保證。是用51單片機(jī)編寫(xiě)的源程序
電路原理圖如下:


Altium Designer畫(huà)的單片機(jī)指紋考勤機(jī)PCB圖如下:(51hei附件中可下載工程文件)


元件清單
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ī)源程序如下:
  1. #include"reg52.h"
  2. #include"12864.h"
  3. #include"eeprom.h"
  4. #include"matrixkey.h"
  5. #include"AT24CXX.h"
  6. #include"finger.h"
  7. uchar code table1[]="A:簽到  B:添加  ";
  8. uchar code table2[]="C:清空  D:上課  ";
  9. uchar code table3[]=" *查詢?nèi)鼻谌藛T  ";
  10. uchar code table4[]=" #查詢遲到人員  ";
  11. uchar code table5[]="請(qǐng)輸入刪去密碼: ";

  12. uchar code table6[]="    開(kāi)始簽到    ";
  13. uchar code table7[]="  請(qǐng)按指紋簽到  ";
  14. uchar code table8[]="               ";
  15. uchar code table9[]="按D:  開(kāi)始上課  ";
  16. uchar code table10[]="請(qǐng)輸入密碼:     ";
  17. uchar code table11[]="    簽到成功    ";
  18. uchar code table12[]="請(qǐng)按任意按鍵繼續(xù)";
  19. uchar code table13[]="  編號(hào)為:      ";
  20. uchar code table14[]="    請(qǐng)按手指    ";
  21. uchar code table15[]="    請(qǐng)?jiān)侔匆淮?nbsp; ";
  22. uchar code table16[]="  采集指紋成功  ";
  23. uchar code table17[]="輸入刪去的指紋號(hào)";
  24. uchar code table18[]="刪去指紋庫(kù)成功  ";
  25. uchar code table19[]="刪去指紋庫(kù)失敗  ";
  26. uchar code table20[]="  請(qǐng)輸入新密碼  ";
  27. uchar code table21[]="請(qǐng)?jiān)俅屋斎胄旅艽a";
  28. uchar code table22[]="  密碼修改成功  ";
  29. uchar code table23[]="  兩次密碼不一樣";
  30. uchar code table24[]="  輸入密碼錯(cuò)誤  ";
  31. uchar code table25[]="  還有  機(jī)會(huì)    ";
  32. uchar code table26[]="  該指紋已存儲(chǔ)  ";
  33. uchar code table27[]="  采集指紋失敗  ";
  34. uchar code table28[]="確定刪去指紋庫(kù)?";
  35. uchar code table29[]="按D:  本節(jié)課結(jié)束";
  36. uchar code table30[]="當(dāng)前缺勤      人";
  37. uchar code table31[]="當(dāng)前遲到      人";
  38. uchar code digital[15]={0x90,0x92,0x94,0x96,0x88,0x8a,0x8c,0x8e,0x98,0x9a,0x9c,0x9e};
  39. uchar  xdata table_qiandao[100];
  40. uchar queqing=0;//缺勤人數(shù)
  41. uchar zz;
  42. uchar chidao=0;//遲到人數(shù)
  43. uchar code     admin[6]={1,3,1,4,2,0};//管理員的固定密碼
  44. uchar code init_code[6]={0,0,0,0,0,0};//上電第一次一般的初始化密碼

  45. uchar   now_code[6]={0,0,0,0,0,0};//當(dāng)前存儲(chǔ)器中存儲(chǔ)的密碼
  46. uchar        user[6]={0,0,0,0,0,0};//用戶輸入的密碼
  47. uchar       user2[6]={0,0,0,0,0,0};//輸入第二次修改的密碼
  48. sbit relay=P3^7;//開(kāi)鎖繼電器
  49. sbit wake=P3^6;//檢測(cè)手指按壓,有手指按下就是高電平
  50. uchar jishu=0;
  51. uchar  err_user=3;//用戶三次輸入錯(cuò)誤密碼
  52. uchar err_admin=3;//管理員三次輸入錯(cuò)誤密碼
  53. uchar num;//存儲(chǔ)矩陣鍵盤(pán)轉(zhuǎn)換的對(duì)應(yīng)按鍵值
  54. uchar number=0;//輸入密碼的個(gè)數(shù)默認(rèn)0
  55. uchar key_flag=0;//進(jìn)入手動(dòng)密碼標(biāo)志
  56. uchar i;
  57. uchar code_flag=0;//密碼修改標(biāo)志第一次輸入密碼時(shí)候是等于0再次輸入是等于1
  58. void init_dispay(void)//初始化界面
  59. {
  60.           PutStr(0,0,table1);
  61.     PutStr(1,0,table2);
  62.                 PutStr(2,0,table3);
  63.                 PutStr(3,0,table4);
  64. }
  65. void admin_dispay(void)//管理員界面
  66. {
  67.          PutStr(0,0,table6);        
  68.    PutStr(1,0,table7);
  69.    PutStr(2,0,table8);        
  70.    PutStr(3,0,table9);                                
  71. }
  72. void init_shuju(void)
  73. {
  74.          uchar i;
  75.          for(i=0;i<100;i++)
  76.             {
  77.                                  table_qiandao[i]=0x00;
  78.                         }
  79. }
  80. void  que_renshu(void)
  81. {  queqing=0;//缺勤人數(shù)
  82. //          WriteCommand(0x80+2);        
  83. //                         WriteData(jishu/10+0x30);
  84. //                         WriteData(jishu%10+0x30);
  85.          for(i=0;i<jishu;i++)
  86.             {
  87.                                  if(table_qiandao[i]==0x00)
  88.                                  {
  89.                                           queqing++;
  90.                                           WriteCommand(digital[queqing-1]);
  91.                                           WriteData((i+1)/10+0x30);
  92.                               WriteData((i+1)%10+0x30);
  93.                                          
  94.                                  }
  95.                         }
  96. }
  97. void  chidao_renshu(void)
  98. {  queqing=0;//缺勤人數(shù)
  99. //         WriteCommand(0x80+2);        
  100. //         WriteData(jishu/10+0x30);
  101. //         WriteData(jishu%10+0x30);
  102.          for(i=0;i<jishu;i++)
  103.             {
  104.                                  if(table_qiandao[i]>=2)
  105.                                  {
  106.                                           queqing++;
  107.                                           WriteCommand(digital[queqing-1]);
  108.                                           WriteData((i+1)/10+0x30);
  109.                               WriteData((i+1)%10+0x30);
  110.                                          
  111.                                  }
  112.                         }
  113. }
  114. void key(void)
  115. {   
  116.            num=keynum();
  117.            if((num==12)&&(key_flag==0))//查看缺勤人數(shù)
  118.                  {
  119.                          LcmClearTXT();//清屏
  120.                          PutStr(0,0,table30);
  121.                          que_renshu();
  122.                          WriteCommand(0x80+6);        
  123.                          WriteData(queqing/10+0x30);
  124.                          WriteData(queqing%10+0x30);
  125.                          while((keynum()>=16));        
  126.        init_dispay();                  
  127.                  }
  128.                  if((num==14)&&(key_flag==0))//查看遲到人數(shù)
  129.                  {
  130.                          LcmClearTXT();//清屏
  131.                          PutStr(0,0,table31);
  132.                          chidao_renshu();
  133.        WriteCommand(0x80+6);        
  134.                          WriteData(queqing/10+0x30);
  135.                          WriteData(queqing%10+0x30);
  136.        while((keynum()>=16));        
  137.                init_dispay();         
  138.                  }
  139.                  if((num==11)&&(key_flag==0))//如果按下C按鍵進(jìn)
  140.                  {
  141.                          key_flag=1;
  142.                          //只顯示“請(qǐng)輸入密碼開(kāi)鎖:“
  143.                          LcmClearTXT();//清屏
  144.                          PutStr(0,0,table28);
  145.        PutStr(1,0,table5);                 
  146.                  }
  147.                  if((num==7)&&(key_flag==0))//如果按下B按鍵進(jìn)入添加指紋
  148.                  {
  149.                         
  150.                           LcmClearTXT();//清屏
  151.           PutStr(1,0,table14);        //顯示請(qǐng)按指紋
  152.                                         if(regist(0)==1)//如果第一次按手指成功
  153.                                          {
  154.                                                    PutStr(1,0,table15);        //顯示請(qǐng)?jiān)侔匆淮?br />
  155.                                                    Delay(10);//延時(shí)一會(huì)
  156.                                                    if(regist(1)==1)//兩次采集手指成功
  157.                                                          {
  158.                                                                    PutStr(1,0,table16);        //采集指紋成功
  159.                    PutStr(2,0,table13);        //指紋編號(hào):
  160.                                                                    WriteCommand(0x88+5);//指定第三行顯示位置
  161.                                                                          WriteData(' ');
  162.                                                                    id=id+1;
  163.                                                                          WriteData(id/100+0x30);
  164.                                                                          WriteData(id%100/10+0x30);
  165.                                                                          WriteData(id%10+0x30);                        
  166.                                                                          SectorErase(0x2200);
  167.                                                                    jishu=id%256;
  168.                    byte_write(0x2200, id%256);
  169.                                                                  
  170.                                                          }
  171.                                                          else PutStr(1,0,table27);        //采集指紋失敗
  172.                                          }
  173.                                          else   if(regist(0)==2)//已經(jīng)注冊(cè)過(guò)指紋
  174.                                                                          {
  175.                                                                                          PutStr(1,0,table26);        //指紋已經(jīng)存儲(chǔ)
  176.                                                                          }
  177.                                        
  178.                                          PutStr(3,0,table12);        //請(qǐng)按任意鍵退出
  179.                                          while(keynum()>=16);           
  180.                                          init_dispay();//管理員設(shè)置界面        
  181.                                          key_flag=0;
  182.                                          num=0xff;
  183.                  }
  184.                  if((num==3)&&(key_flag==0))//如果按下A按鍵管理員模式
  185.                  {
  186.                          key_flag=2;//進(jìn)入輸入管理員密碼界面
  187.                          //只顯示“請(qǐng)輸入密碼:“
  188.                          LcmClearTXT();//清屏
  189.        PutStr(1,0,table10);               
  190.                  }
  191.                  if((key_flag==1)&&(num!=0xff))//非管理員模式下輸入密碼
  192.                  {
  193.                           num=coding(num);//轉(zhuǎn)換成可以識(shí)別的
  194.                           if((number<6)&&(num<10))
  195.                                 {
  196.                                         user[number]=num;//用戶輸入的密碼進(jìn)行記憶
  197.                                         WriteCommand(0x88+number);                //指定第三行顯示位置
  198.                                         WriteData('*');
  199.                                         //WriteData(num+0x30);//明碼顯示        
  200.                                         number++;
  201.                                 }
  202.                                 if((num=='B')&&(number>0))//密碼刪除按鍵
  203.                                                 {  number--;
  204.                                                         WriteCommand(0x88+number);                //指定第三行顯示位置
  205.                                             WriteData(' ');        
  206.                                                 }
  207.                                 if(number==6)//按下D鍵確定按鍵并且輸入六位密碼之后
  208.                                         {  
  209.                                                    LcmClearTXT();//清屏
  210.                                                    number=0;
  211.                                                          key_flag=0;
  212.                                                   //如果管理員密碼正確,進(jìn)入添加指紋,刪除指紋,收到開(kāi)鎖,修改密碼界面
  213.                                                          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]))
  214.                                                          {   
  215.                                                                   if(cancel(0x63)==1)
  216.                                                                                         {
  217.                                                                                                  PutStr(0,0,table18);//輸入刪去的指紋號(hào)成功
  218.                                                                                                  SectorErase(0x2200);
  219.                          byte_write(0x2200, 0x00);                        
  220.                                                                                         }
  221.                                                                                         else
  222.                                                                                         {
  223.                                                                                                  PutStr(0,0,table19);//輸入刪去的指紋號(hào)失敗
  224.                                                                                         }        
  225.                                                                          Delay(80);
  226.                                                     }
  227.                                                          else//密碼錯(cuò)誤
  228.                                                            {
  229.                                                                           PutStr(1,0,table24);//顯示輸入密碼錯(cuò)誤
  230.                                                                         
  231.                                                                         
  232.                                                                  }
  233.                                                          PutStr(3,0,table12);               
  234.                                                          while((keynum()>=16)&&(err_user!=0));
  235.                                                          init_dispay();//初始化界面         
  236.                                         }
  237.                           
  238.                  }
  239.                  if((key_flag==2)&&(num!=0xff))//簽到模式下輸入數(shù)字按鍵
  240.                  {
  241.                                                 num=coding(num);//轉(zhuǎn)換成可以識(shí)別的
  242.                                                 if((number<6)&&(num<10))
  243.                                                 {
  244.                                                         user[number]=num;//用戶輸入的密碼進(jìn)行記憶
  245.                                                         WriteCommand(0x88+number);                //指定第三行顯示位置
  246.                                                         WriteData('*');
  247.                                            // WriteData(num+0x30);        //明碼顯示
  248.                                                         number++;
  249.                                                 }
  250.                                                 if(number==6)//輸入六位以后進(jìn)行密碼校驗(yàn)
  251.                                                 {  //如果管理員密碼正確,進(jìn)入添加指紋,刪除指紋,收到開(kāi)鎖,修改密碼界面
  252.                                                          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]))
  253.                                                          {     
  254.                                                                      key_flag=55;
  255.                                                                      admin_dispay();//進(jìn)入簽到頁(yè)面
  256.                      err_admin=3;
  257.                                                                                   num=0XFF;
  258.                      init_shuju();                                                         
  259.                                                          }
  260.                                                          else//管理員密碼錯(cuò)誤
  261.                                                              {   
  262.                                                                                 
  263.                                                                                         PutStr(1,0,table24);//顯示輸入密碼錯(cuò)誤
  264.                       PutStr(3,0,table12);                                                                                 
  265.                                                                                         while((keynum()>=16)&&(err_admin!=0));
  266.                                                                                         init_dispay();//初始化界面
  267.                       number=0;
  268.                       key_flag=0;                                                                                 
  269.                                                                          }
  270.                               }
  271.                                                 if((num=='B')&&(number>0))
  272.                                                 {  
  273.                                                         number--;
  274.                                                         WriteCommand(0x88+number);                //指定第三行顯示位置
  275.                                             WriteData(' ');        
  276.                                                 }
  277.                                                 
  278.                           
  279.                  }
  280.                  if(key_flag==55)//進(jìn)入簽到指紋巡查
  281.                  {      num=coding(num);//轉(zhuǎn)換成可以識(shí)別的
  282.                               if(num=='D')//按下就進(jìn)入開(kāi)始上課
  283.                                                 {
  284.                                                          key_flag=56;
  285.                                                          PutStr(3,0,table29);
  286.                                                 }
  287.                                      if(wake==1)//如果有手指按下
  288.                                                 {
  289.                                                         if(check()==1)//進(jìn)行指紋匹配
  290.                                                                  {   err_admin=3;
  291.                                                                                  err_user=3;
  292.                                                                                  LcmClearTXT();//清屏
  293.                                                                                  PutStr(1,0,table11);
  294.                                                                                  PutStr(2,0,table13);
  295.                                                                                  WriteCommand(0x88+5);                //指定第三行顯示位置
  296.                                                                                  WriteData(' ');
  297.                                                                            zz=id%256;
  298.                                                                            table_qiandao[zz]=0x01;
  299.                                                                            id++;
  300.                                                                                  WriteData(id/100+0x30);
  301.                                                                                  WriteData(id%100/10+0x30);
  302.                                                                                  WriteData(id%10+0x30);
  303.                      
  304. //                           WriteData(table_qiandao[zz]%100/10+0x30);
  305. //                                                                                 WriteData(table_qiandao[zz]%10+0x30);                                                                                 
  306.                                                                                  relay=0;
  307.                                                                                  Delay(80);
  308.                                                                                  relay=1;
  309.                                                                                  Delay(20);
  310.                                                                                  PutStr(3,0,table12);               
  311.                                                                                  number=0;
  312.                                                                                  key_flag=55;
  313.                                                                                  admin_dispay();//回到初始界面
  314.                                                                                  num=0xff;
  315.                                                                                  
  316.                                                                  }
  317.                                                 }
  318.                  }
  319.                   if(key_flag==56)//遲到的
  320.                  {      num=coding(num);//轉(zhuǎn)換成可以識(shí)別的
  321.                               if(num=='D')//按下就進(jìn)入開(kāi)始上課
  322.                                                 {
  323.                                                          key_flag=0;
  324.                                                          number=0;
  325.                                                          init_dispay();
  326.                                                 }
  327.                                      if(wake==1)//如果有手指按下
  328.                                                 {
  329.                                                         if(check()==1)//進(jìn)行指紋匹配
  330.                                                                  {  
  331.                                                                                  LcmClearTXT();//清屏
  332.                                                                                  PutStr(1,0,table11);
  333.                                                                                  PutStr(2,0,table13);
  334.                                                                                  WriteCommand(0x88+5);                //指定第三行顯示位置
  335.                                                                                  WriteData(' ');
  336.                                                                            zz=id%256;
  337.                                                                            table_qiandao[zz]=table_qiandao[zz]+0x02;
  338.                                                                            id++;
  339.                                                                                  WriteData(id/100+0x30);
  340.                                                                                  WriteData(id%100/10+0x30);
  341.                                                                                  WriteData(id%10+0x30);        
  342.                                                                         
  343. //                                                                           WriteData(table_qiandao[zz]%100/10+0x30);
  344. //                                                                                 WriteData(table_qiandao[zz]%10+0x30);                 
  345.                                                                                  relay=0;
  346.                                                                                  Delay(80);
  347.                                                                                  relay=1;
  348.                                                                                  Delay(20);
  349.                                                                                  PutStr(3,0,table12);               
  350.                                                                                  number=0;
  351.                                                                                  key_flag=56;
  352.                                                                                  admin_dispay();//回到初始界面
  353.                                                                                  PutStr(3,0,table29);
  354.                                                                                  num=0xff;
  355.                                                                  }
  356.                                                 }
  357.                  }
  358.                  
  359. }
  360. void main()        
  361. {  
  362.         for(i=0;i<6;i++)//讀取存儲(chǔ)器中的密碼
  363.      {
  364.                           now_code[i]=read_add(20+i);
  365.               Delay(5);
  366.                  }        
  367.          for(i=0;i<6;i++)
  368.                  {
  369.                           if(now_code[i]>9)
  370.                                 {
  371.                                          i=10;
  372.                                          break;
  373.                                 }
  374.                  }
  375.          if(i>9)//設(shè)置初始化密碼
  376.          
  377.          {
  378.                     for(i=0;i<6;i++)
  379.                                  {
  380.                                                 now_code[i]=init_code[i];
  381.                                                 Delay(5);
  382.                                  }        
  383.          }                                                               
  384.                              
  385.    LcmInit();//初始化12864
  386.          
  387.          
  388.          
  389.          jishu=byte_read(0x2200);
  390. //         WriteCommand(0x88);        
  391. //         WriteData(jishu/10+0x30);
  392. //         WriteData(jishu%10+0x30);
  393. //           Delay(30);
  394. //           Delay(50);
  395.          init_dispay();//進(jìn)入初始化顯示界面
  396.    UART_Init();        //初始化串口9600
  397.          init_shuju();
  398.          while(1)
  399.          {  
  400.                   key();

  401.          }
  402. }
復(fù)制代碼

所有資料51hei附件下載:
指紋考勤.7z (1.51 MB, 下載次數(shù): 87)


評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏6 分享淘帖 頂3 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:1064915 發(fā)表于 2024-3-28 11:25 | 只看該作者
基于51單片機(jī)的指紋考勤機(jī)源程序+PCB文件+原理圖等設(shè)計(jì)資料
http://www.torrancerestoration.com/bbs/dpj-156176-1.html
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表