#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit rs=P3^5;
sbit wr=P3^6;
sbit leden=P3^4;
sbit dula=P2^6;    //数码管段选
sbit wela=P2^7;   //数码管位选
uint i,j;
uchar num;
uchar code table1[]="YL-51 MCU";
uchar code table2[]="WWW.YUNLONGDZ.CN";

void delay(uint x)
{
	for(i=x;i>0;i--)
	{
	for(j=120;j>0;j--);
	}
}

void write_com(uchar com)
{
	rs=0;
	wr=0;
	leden=0;
	P0=com;
	leden=1;
	delay(5);
	leden=0;	
}

void write_data(uchar dat)
{
	rs=1;
	wr=0;
	leden=0;
	P0=dat;
	leden=1;
	delay(5);
	leden=0;	
}

void init()
{
	write_com(0X38);
	write_com(0X08);
	write_com(0X01);
	write_com(0X06);
	write_com(0X0F);
}

void main()
{
	P0=0;    //关闭数码管显示
	dula=0;
	wela=0;
	init();
	for(num=0;num<9;num++)
	{
		write_data(table1[num]);
		delay(300);
	}
	write_com(0X80+0X40);
	for(num=0;num<16;num++)
	{
		write_data(table2[num]);
		delay(300);
	}
	while(1);
}