#include <reg52.h>
#define LCD1602_DB P0
typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned long ulong;
sbit LCD1602_RS = P1^0;
sbit LCD1602_RW = P1^1;
sbit LCD1602_E = P1^5;
void initLCD1602();
void LCDShowStr(uchar i, uchar j, uchar * pCh);
void LCDWaitRdy();
void LCDWrCmd(uchar cmd);
void LCDWrData(uchar dat);
void LCDSetCursor(uchar i, uchar j);
void main() {
initLCD1602();
LCDShowStr(0, 1, "Hello world !");
LCDShowStr(1, 1, "Chasing Waves");
while (1) ;
}
void LCDWaitRdy() {
uchar state;
LCD1602_DB = 0xFF; //使数据总线处于高电平
LCD1602_RS = 0; //选择命令模式
LCD1602_RW = 1; //选择读
do {
LCD1602_E = 1; //开启液晶读写使能
state = LCD1602_DB; //从数据总线上读取状态字
LCD1602_E = 0; //关闭液晶读写使能
} while (state & 0x80); //重复直到bit7 == 0为止(不忙了)
}
void LCDWrCmd(uchar cmd) {
LCDWaitRdy()
51单片机 1602液晶显示静态字符
最新推荐文章于 2023-09-18 09:31:31 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)