久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 4786|回復: 7
打印 上一主題 下一主題
收起左側

五位電子密碼鎖 帶單片機源程序和仿真

[復制鏈接]
跳轉到指定樓層
樓主
電子密碼鎖帶源程序



仿真和全部源碼下載:
電子密碼鎖.zip (28.65 KB, 下載次數: 57)

  1. /***********************************************
  2. *實例名稱:電子密碼鎖
  3. *實例說明:實現五位密碼的設置和解鎖
  4. *作者:yd
  5. *時間:09.06.17
  6. ***********************************************/
  7. #include "target.h"
  8. uchar setPassword[5]={0x01,0x02,0x03,0x04,0x05};  //原始密碼12345
  9. uchar passwordCount;
  10. uchar inputPassword[5]={0x00,0x00,0x00,0x00,0x00};
  11. uchar displayFramCount;         //顯示界面序號,0x01~0x05
  12. void main()
  13. {
  14.   uchar  i;
  15.   uchar  keyValueRead;
  16.   uchar  framTwoLine;  //第二個界面中記錄選擇項所在行數
  17.   target_init();
  18.   displayFramCount=0x01;
  19.   passwordCount=0x00;
  20.   framTwoLine=0x01;   //第二界面中顯示第一行
  21.   while(1)
  22.   {
  23.     switch(displayFramCount)
  24.         {
  25.           case 0x01:
  26.           {
  27.             displayFramOne();
  28.                    break;
  29.           }
  30.           case 0x02:
  31.           {
  32.             if(framTwoLine==0x01)
  33.               displayFramTwo(0);
  34.                 else
  35.                   displayFramTwo(1);
  36.             break;
  37.           }
  38.           case 0x03:
  39.           {
  40.             displayFramThree();
  41.             break;
  42.           }
  43.           case 0x04:
  44.           {
  45.             displayFramFour();
  46.             break;
  47.           }
  48.           case 0x05:
  49.           {
  50.             displayFramFive();
  51.                    break;
  52.           }
  53.           default: break;
  54.         }
  55.         displayFramCount|=0x80;  //displayFramCount最高位置1表示界面已顯示
  56.         keyValueRead=get_key_value();
  57.     switch(keyValueRead)
  58.         {
  59.           case KEY_ONE:
  60.            {
  61.              if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||((displayFramCount&0x7f)==0x04)))
  62.                  {
  63.                    if(passwordCount<0x05)
  64.                    {
  65.                      inputPassword[passwordCount]=0x01;
  66.                          passwordCount++;
  67.                    }
  68.                  }
  69.              break;
  70.            }
  71.           case KEY_TWO:
  72.            {
  73.              if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||((displayFramCount&0x7f)==0x04)))
  74.                  {
  75.                    if(passwordCount<0x05)
  76.                    {
  77.                      inputPassword[passwordCount]=0x02;
  78.                          passwordCount++;
  79.                    }
  80.                  }
  81.              break;
  82.            }
  83.           case KEY_THREE:
  84.            {
  85.              if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||((displayFramCount&0x7f)==0x04)))
  86.                  {
  87.                    if(passwordCount<0x05)
  88.                    {
  89.                      inputPassword[passwordCount]=0x03;
  90.                          passwordCount++;
  91.                    }
  92.                  }
  93.              break;
  94.            }
  95.           case KEY_FOUR:
  96.            {
  97.              if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||((displayFramCount&0x7f)==0x04)))
  98.                  {
  99.                    if(passwordCount<0x05)
  100.                    {
  101.                      inputPassword[passwordCount]=0x04;
  102.                          passwordCount++;
  103.                    }
  104.                  }
  105.              break;
  106.            }
  107.           case KEY_FIVE:
  108.            {
  109.              if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||((displayFramCount&0x7f)==0x04)))
  110.                  {
  111.                    if(passwordCount<0x05)
  112.                    {
  113.                      inputPassword[passwordCount]=0x05;
  114.                          passwordCount++;
  115.                    }
  116.                  }
  117.              break;
  118.            }
  119.           case KEY_SIX:
  120.            {
  121.              if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||((displayFramCount&0x7f)==0x04)))
  122.                  {
  123.                    if(passwordCount<0x05)
  124.                    {
  125.                      inputPassword[passwordCount]=0x06;
  126.                          passwordCount++;
  127.                    }
  128.                  }
  129.              break;
  130.            }
  131.           case KEY_SEVEN:
  132.            {
  133.              if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||((displayFramCount&0x7f)==0x04)))
  134.                  {
  135.                    if(passwordCount<0x05)
  136.                    {
  137.                      inputPassword[passwordCount]=0x07;
  138.                          passwordCount++;
  139.                    }
  140.                  }
  141.              break;
  142.            }
  143.           case KEY_EIGHT:
  144.            {
  145.              if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||((displayFramCount&0x7f)==0x04)))
  146.                  {
  147.                    if(passwordCount<0x05)
  148.                    {
  149.                      inputPassword[passwordCount]=0x08;
  150.                          passwordCount++;
  151.                    }
  152.                  }
  153.              break;
  154.            }
  155.           case KEY_NINE:
  156.            {
  157.             if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||((displayFramCount&0x7f)==0x04)))
  158.                  {
  159.                    if(passwordCount<0x05)
  160.                    {
  161.                      inputPassword[passwordCount]=0x09;
  162.                          passwordCount++;
  163.                    }
  164.                  }
  165.              break;
  166.            }
  167.           case KEY_ZERO:
  168.            {
  169.             if((displayFramCount&0x80)&&(((displayFramCount&0x7f)==0x03)||((displayFramCount&0x7f)==0x04)))
  170.                  {
  171.                    if(passwordCount<0x05)
  172.                    {
  173.                      inputPassword[passwordCount]=0x00;
  174.                          passwordCount++;
  175.                    }
  176.                  }
  177.              break;
  178.            }
  179.           case KEY_TRUE: //確認鍵
  180.            {
  181.              if((displayFramCount&0x80)&&((displayFramCount&0x7f)==0x02)) //設置界面進入輸密碼界面
  182.                  {
  183.                    displayFramCount=0x03;  //解密或者輸密碼時都要進入輸密碼界面
  184.                  }
  185.                  if((displayFramCount&0x80)&&((displayFramCount&0x7f)==0x03))  //輸入密碼確認
  186.                  {
  187.                    if(passwordCount==0x05)
  188.                    {
  189.                      for(i=0;i<5;i++)
  190.                          {
  191.                            if(framTwoLine==0x01)
  192.                            {
  193.                              displayFramCount=0x05;
  194.                            }
  195.                            else
  196.                            {
  197.                              if(framTwoLine==0x02)
  198.                                  {
  199.                                    displayFramCount=0x04;
  200.                                  }
  201.                            }
  202.                           
  203.                            if(inputPassword[i]!=setPassword[i])
  204.                            {
  205.                              displayFramCount=0x01;
  206.                                  break;
  207.                            }
  208.                          }
  209.                          passwordCount=0x00;
  210.                    }
  211.                  }
  212.                  if((displayFramCount&0x80)&&((displayFramCount&0x7f)==0x04))  //設置密碼確認
  213.                  {
  214.                    if(passwordCount==0x05)
  215.                    for(i=0;i<5;i++)
  216.                    {
  217.                     setPassword[i]=inputPassword[i];
  218.                    }
  219.                    displayFramCount=0x01;
  220.                  }
  221.                  break;
  222.            }
  223.           case KEY_CLEAR:    //返回主界面鍵
  224.            {
  225.              displayFramCount=0x01;
  226.                  passwordCount=0x00;
  227.              break;
  228.            }
  229.           case KEY_SET:            //由主界面進入參數設置界面
  230.            {
  231.              if((displayFramCount&0x80)&&((displayFramCount&0x7f)==0x01))
  232.                  {
  233.                    displayFramCount=0x02;
  234.                  }
  235.                  passwordCount=0x00;
  236.              break;
  237.            }
  238.           case KEY_UP:
  239.            {
  240.              if((displayFramCount&0x80)&&((displayFramCount&0x7f)==0x02)) //設置界面中上移選擇行
  241.                  {
  242.                      framTwoLine=0x01;
  243.                          displayFramCount=0x02;     
  244.                  }
  245.              break;
  246.            }
  247.           case KEY_DOWN:
  248.            {
  249.             if((displayFramCount&0x80)&&((displayFramCount&0x7f)==0x02)) //設置界面中上移選擇行
  250.                 {
  251.                    framTwoLine=0x02;
  252.                    displayFramCount=0x02;
  253.                 }
  254.              break;
  255.            }
  256.         }
  257.    if((displayFramCount&0x80)&&((displayFramCount&0x7f)==0x03))  //輸密碼界面,此時顯示****
  258.    {
  259.      displayMima(inputPassword,passwordCount,0x01);
  260.    }
  261.    if((displayFramCount&0x80)&&((displayFramCount&0x7f)==0x04))  //設置密碼界面,此時顯示設置的密碼
  262.    {
  263.      displayMima(inputPassword,passwordCount,0x02);
  264.    }
  265.   }
  266. }
復制代碼


評分

參與人數 1黑幣 +60 收起 理由
admin + 60 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏2 分享淘帖 頂 踩
回復

使用道具 舉報

沙發
ID:63317 發表于 2016-9-16 13:41 | 只看該作者
謝謝分享資料收藏
回復

使用道具 舉報

板凳
ID:121495 發表于 2016-9-26 13:11 | 只看該作者
源程序不全啊
回復

使用道具 舉報

地板
ID:146880 發表于 2016-11-8 19:10 | 只看該作者
cghuvjulh
回復

使用道具 舉報

5#
ID:151629 發表于 2016-12-3 09:21 | 只看該作者
源程序不全嗎
回復

使用道具 舉報

6#
ID:157250 發表于 2016-12-27 23:19 | 只看該作者
很好五位電子密碼鎖
回復

使用道具 舉報

7#
ID:270057 發表于 2018-1-2 11:19 | 只看該作者
想下載文件學習學習
單片機有你更精彩!
回復

使用道具 舉報

8#
ID:265553 發表于 2018-1-14 08:14 來自手機 | 只看該作者
好資料,51黑有你更精彩
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

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

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: hsck成人网| 久久久久av| www.日日操| 久久久激情 | 成人欧美一区二区三区在线播放 | 亚洲一区在线免费观看 | 91精品国产高清久久久久久久久 | 日韩中文字幕网 | 91中文字幕在线 | 欧美精品中文字幕久久二区 | 亚洲日本欧美日韩高观看 | 日韩精品一区二区三区在线观看 | 夜夜爽99久久国产综合精品女不卡 | www.国产精品| 亚洲一区二区三区免费在线观看 | 国产一区亚洲 | 中文日韩在线视频 | 超碰97免费观看 | 亚洲三区在线观看 | 99影视 | 国产精品一区二区av | 午夜激情影院 | 男人天堂av网站 | 亚洲精品中文字幕中文字幕 | 一区二区在线看 | 精品国产一区二区三区在线观看 | 欧美成年黄网站色视频 | 免费一区在线观看 | 成人免费一区二区三区视频网站 | 欧美精品一区二区免费 | 亚洲国产情侣自拍 | 中文字幕第5页 | 在线观看特色大片免费网站 | 国产成人高清在线观看 | 亚洲情综合五月天 | 在线观看涩涩视频 | 成人国产精品一级毛片视频毛片 | 免费看国产精品视频 | 欧美 日韩 国产 一区 | 国产精品毛片无码 | 欧美日韩国产中文字幕 |