標(biāo)題: 4*6行列鍵盤的單片機(jī)驅(qū)動(dòng)源程序 [打印本頁]

作者: iCekrY    時(shí)間: 2018-10-24 16:29
標(biāo)題: 4*6行列鍵盤的單片機(jī)驅(qū)動(dòng)源程序
引腳參照圖片

單片機(jī)源程序如下:

#include <STC89.H>
#include "Keypad.h"

//                                                鍵值   鍵釋放時(shí)間 鍵按下時(shí)間
char KeyNum;
unsigned int  KeyUpCnt,KeyDownCnt;


char KeyScan()
{
        P1 |= 0xFC;
        P2 = (P2&0xF0) | (0x0E);
          if(!P17)return 0x11;//ON/C
          if(!P16)return '7'; //7
          if(!P15)return '8'; //8
          if(!P14)return '9'; //9
          if(!P13)return '*'; //x
          if(!P12)return '/'; //÷
        
        P1 |= 0xFC;
        P2 = (P2&0xF0) | (0x0D);
          if(!P17)return 0x12;//+/-
          if(!P16)return '4';   //4
          if(!P15)return '5';   //5
          if(!P14)return '6';   //6
          if(!P13)return '-'; //-
          if(!P12)return 0x13;//MRC
        
        P1 |= 0xFC;
        P2 = (P2&0xF0) | (0x0B);
          if(!P17)return '%'; //%
          if(!P16)return '1';   //1
          if(!P15)return '2';   //2
          if(!P14)return '3';   //3
          if(!P13)return '+'; //+
          if(!P12)return 0x14;//M-
               
        P1 |= 0xFC;
        P2 = (P2&0xF0) | (0x07);
          if(!P17)return '?'; //?
          if(!P16)return '0';   //0
          if(!P15)return '.'; //.
          if(!P14)return '='; //=
          if(!P13)return '+'; //+
          if(!P12)return 0x15;//M+
               
        P2 = (P2&0xF0) | (0x0F);
        return -1;
}



全部資料51hei下載地址:
4x6行列鍵盤驅(qū)動(dòng).rar (3.43 KB, 下載次數(shù): 13)








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