欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 原創:單片機矩陣鍵盤按鍵信息輸出proteus仿真+源碼 [打印本頁]

作者: With_commands    時間: 2018-1-13 10:31
標題: 原創:單片機矩陣鍵盤按鍵信息輸出proteus仿真+源碼
原創輸出程序
晶振的速度與掃描輸出無關
晶振速度越快,掃描速度就越快
建議是12MHz,12T模式
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)







單片機源程序如下:
  1. #include <reg52.h>
  2. #include "lcd.c"

  3. #define GPIO_KEY P1

  4. uchar KeyValue;
  5. //存放捕獲到的鍵值
  6. uchar KeyState;

  7. const uchar dat[]="0123456789ABCDEF";

  8. const uchar output[]={      //單個16進制
  9. 0xf0,0xf1,0xf2,0xf3,
  10. 0xf4,0xf5,0xf6,0xf7,
  11. 0xf8,0xf9,0xfa,0xfb,
  12. 0xfc,0xfd,0xfe,0xff
  13. };

  14. void Delay10ms()   //延時10毫秒,誤差0微秒
  15. {
  16.     uchar a,b,c;
  17.     for(c=1;c>0;c--)
  18.         for(b=38;b>0;b--)
  19.             for(a=130;a>0;a--);
  20. }

  21. void keyscan()
  22. {
  23.         char a;
  24.         GPIO_KEY=0x0f;
  25.         if(GPIO_KEY!=0x0f)
  26.         {
  27.                 Delay10ms();
  28.                 if(GPIO_KEY!=0x0f)
  29.                 {
  30.                         KeyState=1;
  31.                         //測試列
  32.                         GPIO_KEY=0X0F;
  33. //                         Delay10ms();
  34.                         switch(GPIO_KEY)
  35.                         {
  36.                                 case(0X07):        KeyValue=0;break;
  37.                                 case(0X0b):        KeyValue=1;break;
  38.                                 case(0X0d): KeyValue=2;break;
  39.                                 case(0X0e):        KeyValue=3;break;
  40. //                                default:        KeyValue=17;        //檢測出錯回復17意思是把數碼管全滅掉
  41.                         }
  42.                         //測試行
  43.                         GPIO_KEY=0XF0;
  44.                         Delay10ms();
  45.                         switch(GPIO_KEY)
  46.                         {
  47.                                 case(0X70):        KeyValue=KeyValue;break;
  48.                                 case(0Xb0):        KeyValue=KeyValue+4;break;
  49.                                 case(0Xd0): KeyValue=KeyValue+8;break;
  50.                                 case(0Xe0):        KeyValue=KeyValue+12;break;
  51. //                                default:        KeyValue=17;
  52.                         }
  53.                         while((a<50)&&(GPIO_KEY!=0xf0))         //檢測按鍵松手檢測
  54.                         {
  55.                                 Delay10ms();
  56.                                 a++;
  57.                         }
  58.                         a=0;
  59.                 }
  60.         }
  61. }

  62. void main()
  63. {
  64.         P3=0xf0;
  65.         LcdInit();
  66.         LcdPrintf("by:With commands");
  67.         while(1)
  68.         {
  69.                 keyscan();
  70.                 if(KeyState)
  71. ……………………

  72. …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼

所有資料51hei提供下載:
button.zip (49.73 KB, 下載次數: 46)







作者: 技術求助    時間: 2018-1-14 07:21
不錯,很想學習
作者: tim9996    時間: 2021-7-16 10:23
好東西先學習下程序




歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1