51单片机89C52一个关于1602液晶显示的程序提问(以下是我写的程序...但是1602愣是什么都不显示.能正常发光
#include<reg52.h>#defineucharunsignedchar#defineuintunsignedintsbitlcden=P3^4;sbitlcd...
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit lcden=P3^4;
sbit lcdrs=P3^5;
sbit dula=P2^6;
sbit wela=P2^7;
void delay(uint);
void init();
void write_com(uchar);
void write_dat(uchar);
void main()
{
init();
write_dat(1);
while(1);
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void init()
{
dula=0;
wela=0;
lcden=0;
write_com(0x38);
delay(5);
write_com(0x38);
write_com(0x0f);
write_com(0x06);
write_com(0x80);
}
void write_com(uchar com)
{
lcdrs=0;//rs=0是写指令!
P0=com;
delay(5);
lcden=1;//使能端一高一低产生高脉冲!
delay(5);
lcden=0;
}
void write_dat(uchar dat)
{
lcdrs=1;//rs=1是写数据!
P0=dat;
delay(5);
lcden=1;
delay(5);
lcden=0;
} 展开
#define uchar unsigned char
#define uint unsigned int
sbit lcden=P3^4;
sbit lcdrs=P3^5;
sbit dula=P2^6;
sbit wela=P2^7;
void delay(uint);
void init();
void write_com(uchar);
void write_dat(uchar);
void main()
{
init();
write_dat(1);
while(1);
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void init()
{
dula=0;
wela=0;
lcden=0;
write_com(0x38);
delay(5);
write_com(0x38);
write_com(0x0f);
write_com(0x06);
write_com(0x80);
}
void write_com(uchar com)
{
lcdrs=0;//rs=0是写指令!
P0=com;
delay(5);
lcden=1;//使能端一高一低产生高脉冲!
delay(5);
lcden=0;
}
void write_dat(uchar dat)
{
lcdrs=1;//rs=1是写数据!
P0=dat;
delay(5);
lcden=1;
delay(5);
lcden=0;
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询