单片机:lcd问题!求助!
时间:10-02
整理:3721RD
点击:
大神们!求助!lcd1602液晶显示屏只显示一行,想在第二行显示为何都显示不出来?求助!
#include<reg51.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
#define lcd P0
sbit rs=P2^6;
sbit rw=P2^5;
sbit e=P2^7;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void jianche_bf()
{
char i,x=0x80;
while(x&0x80)
{
rs=0;rw=1;
e=1;
x=lcd;
e=0;
for(i=0;i<10;i++);
}
}
void xiezhiling(char zhiling)
{
rs=0;rw=0;
e=1;
lcd=zhiling;
e=0;
jianche_bf();
}
void xieshuju(char shuju)
{
rs=1;rw=0;
e=1;
lcd=shuju;
e=0;
jianche_bf();
}
void chushihua()
{
xiezhiling(0x38);
xiezhiling(0x0c);
xiezhiling(0x01);
xiezhiling(0x08);
xiezhiling(0x06);
xiezhiling(0x0e);
}
uchar i;
main()
{
uchar a[]="a bcde aaa!";
char b[]="luo xiang cheng ";
chushihua();
while(1)
{
xiezhiling(0x80);
for(i=0;i<16;i++)
xieshuju(b[i]);
delay(1000);
xiezhiling(0x80+0x40);
for(i=0;i<11;i++)
xieshuju(a[i]);
delay(1000);
}
}
#include<reg51.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
#define lcd P0
sbit rs=P2^6;
sbit rw=P2^5;
sbit e=P2^7;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void jianche_bf()
{
char i,x=0x80;
while(x&0x80)
{
rs=0;rw=1;
e=1;
x=lcd;
e=0;
for(i=0;i<10;i++);
}
}
void xiezhiling(char zhiling)
{
rs=0;rw=0;
e=1;
lcd=zhiling;
e=0;
jianche_bf();
}
void xieshuju(char shuju)
{
rs=1;rw=0;
e=1;
lcd=shuju;
e=0;
jianche_bf();
}
void chushihua()
{
xiezhiling(0x38);
xiezhiling(0x0c);
xiezhiling(0x01);
xiezhiling(0x08);
xiezhiling(0x06);
xiezhiling(0x0e);
}
uchar i;
main()
{
uchar a[]="a bcde aaa!";
char b[]="luo xiang cheng ";
chushihua();
while(1)
{
xiezhiling(0x80);
for(i=0;i<16;i++)
xieshuju(b[i]);
delay(1000);
xiezhiling(0x80+0x40);
for(i=0;i<11;i++)
xieshuju(a[i]);
delay(1000);
}
}
看别人的代码好痛苦
这个问题解决没有啊?
试试第二行的地址设置直接用0XC0,不用0x80+0x40,程序似乎没问题,最好能贴个图片,看看显示的状态。