1602液晶移屏一段程序看不懂,请大家给我解释一下,谢谢。
时间:10-02
整理:3721RD
点击:
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]="Hello everyone!";
uchar code table1[]="Welcome to here!";
sbit lcden=P2^5;
sbit lcdrs=P1^0;
sbit lcdrw=P1^1;
sbit dula=P2^6;
sbit wela=P2^7;
uchar num,num1;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void write_com(uchar com)
{
lcdrs=0;
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_data(uchar date)
{
lcdrs=1;
P0=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void init()
{
dula=0;
wela=0;
lcdrw=0;
lcden=0;
write_com(0x38);
write_com(0x0f);
write_com(0x06);
write_com(0x01);
}
void main()
{
init();
write_com(0x80+0x10);
for(num=0;num<15;num++)
{
write_data(table[num]);
delay(5);
}
write_com(0x07);
write_com(0x80+0x50);
for(num1=0;num1<16;num1++)
{
write_data(table1[num1]);
delay(200);
}
while(1);
}
其中红色一句怎么理解,请大家给以讲解,谢谢了先。
#define uchar unsigned char
#define uint unsigned int
uchar code table[]="Hello everyone!";
uchar code table1[]="Welcome to here!";
sbit lcden=P2^5;
sbit lcdrs=P1^0;
sbit lcdrw=P1^1;
sbit dula=P2^6;
sbit wela=P2^7;
uchar num,num1;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void write_com(uchar com)
{
lcdrs=0;
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_data(uchar date)
{
lcdrs=1;
P0=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void init()
{
dula=0;
wela=0;
lcdrw=0;
lcden=0;
write_com(0x38);
write_com(0x0f);
write_com(0x06);
write_com(0x01);
}
void main()
{
init();
write_com(0x80+0x10);
for(num=0;num<15;num++)
{
write_data(table[num]);
delay(5);
}
write_com(0x07);
write_com(0x80+0x50);
for(num1=0;num1<16;num1++)
{
write_data(table1[num1]);
delay(200);
}
while(1);
}
其中红色一句怎么理解,请大家给以讲解,谢谢了先。
整屏左移
那么显示第二行不需要再来一句 write_com(0x07); 吗?