#include<reg51.h>
#define uint unsigned int
uchar code table[]="W J H";
uchar code table1[]="I LOVE Long";
sbit en=P3^4;
sbit rw=P3^3;
sbit rs=P3^5;
sbit dula=P2^6;
sbit wela=P2^7;
uchar num;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void write_com(uchar com)
{
rs=0;
rw=0;
P0=com;
delay(5);
en=0;
delay(5);
en=1;
delay(5);
en=0;
}
void write_data(uchar date)
{
rs=1;
rw=0;
P0=date;
delay(5);
en=0;
delay(5);
en=1;
delay(5);
en=0;
}
void init()
{
dula=0;
wela=0;
en=0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
}
void main()
{
init();
write_com(0x80);
for(num=0;num<5;num++)
{
write_data(table[num]);
delay(5);
}
write_com(0x80+0x40);
for(num=0;num<11;num++)
{
write_data(table1[num]);
delay(5);
}
while(1);
}
-
实物图
不懂就问
一周热门 更多>