×
单片机 > 单片机程序设计 > 详情

设定1602字符的显示位置

发布时间:2020-08-27 发布时间:
|
2行 5*8 16字符LCD显示方式的地址映射:

 

对应地址:     0x00   0x01   0x02  0x03  0x04   0x05   0x06   0x07

D0-D7的值:     0x80   0x81   0x82  0x83  0x84   0x85   0x86   0x87

对应地址:     0x40   0x41   0x42  0x43  0x44   0x45   0x46   0x47

D0-D7的值:    0xC0   0xC1   0xC2  0xC3  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);
}




『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
C8051F020的UART