红外发射程序键值在LCD1602上显示实例程序

loading 分享 2026-8-20 下载文档

LCD1602显示键值程序:

#include #include

#define uchar unsigned char #define uint unsigned int

#define delayNOP(); {_nop_();_nop_();_nop_();_nop_();};

void delay(uchar x); //x*0.14MS void delay1(int ms); void beep();

sbit IRIN = P3^3; //紅外接收器數據線 sbit BEEP = P1^5; //蜂鳴器驅動線 sbit RELAY= P1^4; //繼電器驅動線

uchar IRCOM[7];

sbit LCD_RS = P2^3; sbit LCD_RW = P2^4; sbit LCD_EN = P2^5;

uchar code cdis1[ ] = {%uchar code cdis2[ ] = {\

/*******************************************************************/

/* */ /**/

/*lcd_busy爲1時,忙,等待。lcd-busy爲0時,閑,可寫指令與數據。 */

/* */

/*******************************************************************/

bit lcd_busy()

{ bit result; LCD_RS = 0; LCD_RW = 1;

LCD

LCD_EN = 1; delayNOP();

result = (bit)(P0&0x01); LCD_EN = 0; return(result); }

/*******************************************************************/

/* */ /**/

LCD

/*RS=L,RW=L,E=高脈衝,D0-D7=指令碼。 */

/* */

/*******************************************************************/

void lcd_wcmd(uchar cmd)

{ while(lcd_busy()); LCD_RS = 0; LCD_RW = 0; LCD_EN = 0; _nop_(); _nop_(); cmd

=

((cmd&0x01)<<7)|((cmd&0x02)<<5)|((cmd&0x04)<<3)|((cmd&0x08)<<1)|((cmd&0x10)>>1)|((cmd&0x20)>>3)|((cmd&0x40)>>5)|((cmd&0x80)>>7); P0 = cmd; delayNOP(); LCD_EN = 1; delayNOP(); LCD_EN = 0; }

/*******************************************************************/

/* */


红外发射程序键值在LCD1602上显示实例程序.doc 将本文的Word文档下载到电脑
搜索更多关于: 红外发射程序键值在LCD1602上显示实例程序 的文档
相关推荐
相关阅读