標(biāo)題: 基于51單片機的矩陣鍵盤掃描keil程序+Proteus原理圖 [打印本頁]

作者: fwc0315    時間: 2018-5-21 19:12
標(biāo)題: 基于51單片機的矩陣鍵盤掃描keil程序+Proteus原理圖
上一個帖子忘記加附件了
單片機矩陣鍵盤數(shù)碼管顯示仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)


單片機源程序如下:
  1. #include <reg51.h>
  2. #include <stdio.h>

  3. #define byte unsigned char

  4. //中斷服務(wù)程序
  5. void keyinterrupt()   interrupt 2
  6. {
  7.         int t;
  8.         byte keycode,scancode,flag=0xff;
  9.         t=5000;
  10.         while(t--);
  11.         if(INT1==1)
  12.                 return;
  13.         EX1=0;
  14.         scancode=0xef;
  15.         while(scancode!=0xff)
  16.         {
  17.                 P1=scancode;
  18.                 keycode=P1;
  19.                 if((keycode&0x0f)!=0x0f)
  20.                         break;
  21.                 scancode=(keycode<<1)|0x0f;
  22.         }
  23.         keycode=~keycode;

  24.         P2=keycode; //將掃描碼輸出,數(shù)碼管采用具有譯碼功能的數(shù)碼管
  25.         P1=0X0F;
  26.         while(1)
  27.         {
  28.                 if(INT1==1)
  29.                 {
  30.                         flag=~flag;
  31.                         if(flag==0)
  32.                         break;
  33.                 }
  34.                 t=10000;
  35.                 while(t--);
  36.         }
  37.         EX1=1;
  38.         return;
  39. }

  40. void main(void)
  41. {   
  42.         IE=0;
  43.         EX1=1;
  44.         EA=1;  //中斷open
  45.         P2=0XFF;
  46.         P1=0X0F;
  47.     while(1)
  48.     {               
  49.         }                  
  50. }
復(fù)制代碼

所有資料51hei提供下載:
矩陣鍵盤數(shù)碼管顯示.rar (37.39 KB, 下載次數(shù): 25)



作者: txr999    時間: 2020-1-29 11:46
很好的資料,學(xué)習(xí)了!




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