本人新手,求大神解救。附上所编程序,以及液晶显示状况,求帮助。。。
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit dula=P2^6;
sbit wela=P2^7;
sbit lcden=P1^6;
sbit lcdrs=P2^1;
sbit lcdrw=P1^5;
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 dat)
{
lcdrs=1;
P0=dat;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void init()
{
dula=0;
wela=0;
lcden=0;
lcdrw=0;
write_com(0x38);
write_com(0x0e);
write_com(0x06);
write_com(0x01);
}
void main()
{
init();
write_data('a');
while(1);
}
一周热门 更多>