这是程序
#include<reg52.h>
sbit lcden=P1^0;
sbit lcdrs=P1^1;
sbit lcdrw=P1^2;
void delay(unsigned int z)
{
unsigned int x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void write_com(unsigned char com)
{
lcdrs=0;
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_data(unsigned char date)
{
lcdrs=1;
P0=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void init()
{
lcdrw=0;
lcden=0;
write_com(0x38);
write_com(0x0e);
write_com(0x06);
write_com(0x01);
write_com(0x80+0x10);
}
void main()
{
init();
write_data('a');
while(1);
} |