51鍵盤及數字輸入顯示
主程序
LCD.C文件
LCD.H文件- #ifndef __LCD_H_
- #define __LCD_H_
- /**********************************
- 當使用的是4位數據傳輸的時候定義,
- 使用8位取消這個定義
- **********************************/
- //#define LCD1602_4PINS
- /**********************************
- 包含頭文件
- **********************************/
- #include<reg51.h>
- //---重定義關鍵詞---//
- #ifndef uchar
- #define uchar unsigned char
- #endif
- #ifndef uint
- #define uint unsigned int
- #endif
- /**********************************
- PIN口定義
- **********************************/
- #define LCD1602_DATAPINS P0
- sbit LCD1602_E=P2^7;
- sbit LCD1602_RW=P2^5;
- sbit LCD1602_RS=P2^6;
- /**********************************
- 函數聲明
- **********************************/
- /*在51單片機12MHZ時鐘下的延時函數*/
- void Lcd1602_Delay1ms(uint c); //誤差 0us
- /*LCD1602寫入8位命令子函數*/
- void LcdWriteCom(uchar com);
- /*LCD1602寫入8位數據子函數*/
- void LcdWriteData(uchar dat) ;
- /*LCD1602初始化子程序*/
- void LcdInit();
- #endif
復制代碼
|