#include
#define uint unsigned int
#define uchar unsigned char
sbit lcdrs=P3^0;
sbit lcdrw=P3^1;
sbit lcden=P3^2;
uchar tt[]=" I like 51MCU! ";
uchar tt1[]=" ";
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;//将数据传给P0
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_dat(uchar dat)
{
lcdrs=1;//写数据
P0=dat;//将数据传给P0
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void init()
{
lcden=0;
lcdrw=0;
//write_com(0x01);
write_com(0x38);
write_com(0x0f);
write_com(0x06);
write_com(0x01);
write_com(0x80);
}
void main()
{
uint x,y;
init();
for(x=0;x<16;x++)
{
write_dat(tt[x]);
delay(200);
}
write_com(0x01);
write_com(0x80+0x50);//重新设置数据指针
for(x=0;x<16;x++)
{
write_dat(tt1[x]);
delay(200);
}
for(y=0;y<15;y++)
{
write_com(0x18);//显示整平左移
delay(20);
}
while(1);
}
阅读(640) | 评论(0) | 转发(0) |