#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
uint num,num1;
uchar table[]="I LIKE MCU!";
uchar table1[]="WWW:ZWP520.COM";
sbit lcdrs=P3^5;
sbit lcden=P3^4;
sbit dula=P2^6;
sbit wela=P2^7;
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 date) //写数据
{
lcdrs=1;
P0=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void init() //函数初始化
{
dula=0;
wela=0;
lcden=0;
write_com(0x38);
write_com(0x0e);
write_com(0x06);
write_com(0x01);
write_com(0x80);
}
void main()
{
init();
for(num=0;num<11; num++) //写第一行
{
write_data(table[num]);
delay(20);
}
// write_com(1);
write_com(0x80+0x53);
for(num=0;num<14; num++) //写第二行
{
write_data(table1[num]);
delay(20);
}
for(num=0;num<16;num++) //全屏移动
{
write_com(0x18);
delay(200);
}
while(1);
} |