关于LM016第二行显示不出来的问题,谢谢
第一行能显示出来,第二行就不行。程序有点长求大家帮我看看,万分感谢!
#include<reg52.h>
sbit rs=P2^0;
sbit lcden=P2^1;
int num;
unsigned char code table[]="The pressure is:"; //第一行
unsigned char code table1[]="100Pa"; //第二行
void delay(unsigned int t) //延时tms
{
unsigned int i,j;
for(i=5;i>0;i--)
for(j=82*t;j>0;j--);
}
void write_command(unsigned char command) //写命令
{
rs=0;
P0=command;
delay(5);
lcden=0;
delay(5);
lcden=1;
}
void write_dat(unsigned char dat) //写数据
{
rs=1;
P0=dat;
delay(5);
lcden=0;
delay(5);
lcden=1;
}
void init() //初始化
{
lcden=0;
write_command(0x38);
write_command(0x0f);
write_command(0x06);
write_command(0x01);
}
void main()
{
init();
delay(200);
write_command(0x80);
for(num=0;num<16;num++) //只能显示第一行
{
write_dat(table[num]);
delay(5);
}
write_command(0x80+0x40); //第二行显示不了
for(num=0;num<5;num++)
{
write_dat(table1[num]);
delay(5);
}
while(1);
}