2行 5*8 16字符LCD显示方式的地址映射:
本文引用地址:https://www.eepw.com.cn/article/201611/319277.htm对应地址: 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07
D0-D7的值: 0x80 0x81 0x820x83 0x84 0x85 0x86 0x87
对应地址: 0x400x410x420x43 0x44 0x45 0x46 0x47
D0-D7的值: 0xC00xC10xC20xC3 0xC4 0xC5 0xC6 0xC7
代码实现(使用setDisplayPosition函数,第一个参数为字符也可为ASCII码,第二个为上面的D0-D7对应的值,想显示哪个位置,就放入哪个地址参数):
void delay(int x)//延时Xms
{
char y;
while(x--)
for(y=110;y>0;y--);
}
void write_date(char date)//写数据
{
lcdrs=1;
P0=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
write_position(char date)
{
lcdrs=0;
lcdrw=0;
P0=position;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void setDisplayPosition(char date,char position)
{
write_position(position);
write_date(date);
}
评论