LCD1602控制总线模式
时间:09-08
来源:互联网
点击:
第一行显示"Welcome";第二行显示="Happy day";若要显示其他字符,请直接往数组 LCMLineOne[16]和LCMLineTwo[16]填充相应的代码。直接上图,仿真图如下:
![](../img/eep/emb/emb-30863t4aphuqyaej.jpg)
![](../img/eep/emb/emb-30863t4aphuqyaej.jpg)
源程序如下,可以对比时序方式,理解总线的操作方法。#includereg51.h>//#includeabsacc.h>#define uchar unsigned char#define uint unsigned int #define busy 0x80uchar xdata LCMWriteCOM _at_ 0x80ff; //写指令寄存器uchar xdata LCMReadCOM _at_ 0xa0ff ; //读指令寄存器uchar xdata LCMWriteData _at_ 0xc0ff ; //写数据寄存器uchar xdata LCMReadData _at_ 0xe0ff ; //读数据寄存器uchar data LCMLineOne[16]="Welcome"; //第一行显示的数据uchar data LCMLineTwo[16]="Happy day"; //第二行显示的数据void Delayms(uchar ms){uchar i,j;for(i=0;ims;i++)for(j=0;j57;j++);}//写指令寄存器void LCMWriteC(uchar COMData){ uchar LCMStatus;do{LCMStatus=(LCMReadCOMbusy); }while(LCMStatus!=0);LCMWriteCOM=COMData;}//读指令寄存器uchar LCMReadC(){uchar LCMStatus;do{LCMStatus=(LCMReadCOMbusy); }while(LCMStatus!=0);LCMStatus=LCMReadCOM;return(LCMStatus);}//读数据寄存器uchar LCMReadD(uchar addr){uchar LCMStatus;do{LCMStatus=(LCMReadCOMbusy); }while(LCMStatus!=0);LCMWriteC(0x80+addr);LCMStatus=LCMReadData;return(LCMStatus);}//写数据寄存器带地址void LCMWriteDAdd(uchar addr,uchar LCMData){uchar LCMStatus;do{LCMStatus=(LCMReadCOMbusy); }while(LCMStatus!=0);LCMWriteC(0x80+addr);LCMWriteData=LCMData;}//写数据寄存器无地址void LCMWriteD(uchar LCMData){uchar LCMStatus;do{LCMStatus=(LCMReadCOMbusy); }while(LCMStatus!=0);LCMWriteData=LCMData;}//初始化void LCMInit(void){ Delayms(15);LCMWriteCOM=0x38;Delayms(5);LCMWriteCOM=0x38;Delayms(5);LCMWriteCOM=0x38;Delayms(5);LCMWriteC(0x38);LCMWriteC(0x08);LCMWriteC(0x01);LCMWriteC(0x06);LCMWriteC(0x0c);}main(){ uchar i;LCMInit();while(1){ LCMWriteC(0x80); //第一行开始地址for(i=0;i16;i++)LCMWriteD(LCMLineOne[i]);LCMWriteC(0x80+0x40); //第二行开始地址for(i=0;i16;i++)LCMWriteD(LCMLineTwo[i]);}}
- 单片机定时器实现实时时钟程序-lcd1602显示(12-02)
- 单片机写LCD1602液晶程序源码(12-02)
- 单片机I2C通信及LCD1602显示C程序(12-02)
- 单片机LCD1602底层驱动子程序(12-02)
- 51单片机加HC—SR04超声波测距仪用LCD1602显示(12-02)
- PIC单片机驱动LCD1602液晶显示字符串程序(12-02)