#include"reg52.h"
#define uchar unsigned char
uchar dd[]="Electronic Of SX";
uchar dd1[]="Science collage";
sbit rs=P2^3;
sbit en=P2^4;
sbit sh=P2^1;
sbit st=P2^2;
sbit DO=P2^0;
sbit cr=P2^5;
void delay(unsigned int ss)
{
while(ss--);
}
void w1602c(uchar dat)
{
char i;
P2 &=~0x1f;
for(i=8;i>0;i--)
{
if((dat & (1<<(i-1)))==(1<<(i-1)))
DO=1;
else
DO=0;
sh=1;
sh=0;
st=1;
st=0;
}
delay(4);
en=1;
delay(4);
en=0;
}
void w1602d(uchar dat)
{
char i;
P2 |=0x08;
P2 &=~0x7;
for(i=8;i>0;i--)
{
if((dat & (1<<(i-1)))==(1<<(i-1)))
DO=1;
else
DO=0;
sh=1;
sh=0;
st=1;
st=0;
}
delay(5);
en=1;
delay(5);
en=0;
}
void init1602()
{
w1602c(0x38);
w1602c(0x06);
w1602c(0x0c);
w1602c(0x01);
}
void main()
{
char n;
init1602();
while(1)
{
w1602c(0x80);
for(n=0;n<16;n++)
w1602d(dd[n]);
w1602c(0xc0);
for(n=0;n<16;n++)
w1602d(dd1[n]);
}
}
|