#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
void write_com(uchar com);
void write_date(uchar dat);
void delay(uint);
void init();
uchar code table[]="I LIKE WMY";
uchar code table1[]="I LIKE LSF";
sbit E=P2^7;
sbit RW=P2^5;
sbit RS=P2^6;
uint num;
void main()
{
init();
for(num=0;num<10;num++)
{
write_date(table[num]);
delay(20);
}
write_com(0x80+0x40);
for(num=0;num<10;num++)
{
write_date(table1[num]);
delay(20);
}
while(1);
}
void init()
{
RW=0;
E=0;
write_com(0x38);
write_com(0x0f);
write_com(0x06);
write_com(0x01);
write_com(0x80);
}
void write_com(uchar com)
{
RS=0;
P0=com;
delay(10);
E=1;
delay(10);
E=0;
}
void write_date(uchar dat)
{
RS=1;
P0=dat;
// delay(1);
E=1;
delay(1);
E=0;
}
void delay(uint x)
{
uint i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
void write_com(uchar com);
void write_date(uchar dat);
void delay(uint);
void init();
uchar code table[]="I LIKE WMY";
uchar code table1[]="I LIKE LSF";
sbit E=P2^7;
sbit RW=P2^5;
sbit RS=P2^6;
uint num;
void main()
{
init();
for(num=0;num<10;num++)
{
write_date(table[num]);
delay(20);
}
write_com(0x80+0x40);
for(num=0;num<10;num++)
{
write_date(table1[num]);
delay(20);
}
while(1);
}
void init()
{
RW=0;
E=0;
write_com(0x38);
write_com(0x0f);
write_com(0x06);
write_com(0x01);
write_com(0x80);
}
void write_com(uchar com)
{
RS=0;
P0=com;
delay(10);
E=1;
delay(10);
E=0;
}
void write_date(uchar dat)
{
RS=1;
P0=dat;
// delay(1);
E=1;
delay(1);
E=0;
}
void delay(uint x)
{
uint i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
|