|
# include <reg52.h>
# define uchar unsigned char
# define uint unsigned int
sbit lcden = P3^4;
sbit lcdrs = P3^5;
void init();
void delay(uint z);
void write_com(uchar com);
void write_data(uchar date);
void main()
{
init();
write_data('1');
while(1);
}
void delay(uint z)
{
uint x, y;
for(x=z; x>0; x--)
for(y=110; y>0; y--);
}
void init()
{
lcden = 0;
write_com(0x38);
write_com(0x0f);
write_com(0x06);
write_com(0x01);
write_com(0x80);
}
void write_com(uchar com)
{
lcdrs = 0;
P0 = com;
delay(5);
lcden = 1;
delay(5);
lcden = 0;
}
void write_data(uchar date)
{
lcdrs = 1;
P0 = date;
delay(5);
lcden = 1;
delay(5);
lcden = 0;
}
|
|