#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit h_diola=P2^5;   //对控制点阵行选的74HC573（U10）锁存端进行位定义
sbit l_dula=P2^6;    //对控制点阵列选的74HC573（U1）锁存端进行位定义
sbit wela=P2^7;
uchar code l_table[]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC3,0xE7,0xE7,
                      0xE7,0xE7,0xE7,0xC3,0xFF,0x99,0x00,0x00,0x00,0x81,0xC3,
                      0xE7,0xFF,0x60,0x3E,0x7E,0x70,0x6F,0x6F,0x6E,0x71,0xFF,
                      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};  //列选编码（显示 我爱51）
uchar code h_table[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};  //行选编码

delay(uint t)     //延时函数
{
	while(t--);
}

void main()    //主函数
{	
	uchar i,j,k,z;
	P0=0xff;   //关闭数码管
	wela=1;
	wela=0; 
	while(1)
	{
		z=50;
		while(z--)  //让每张图像多扫描几次
		{
			for(i=0;i<8;i++)     //用一个for 循环，从第1行到第8行，按顺序的进行扫描
			{
				P0=l_table[j++];   //依次送入列选编码
				l_dula=1;
				l_dula=0;

				P0=h_table[i];    //依次送入行选编码
				h_diola=1;
				h_diola=0;

				delay(200);   //延时约2ms

				P0=0X00;    //点阵清屏
				h_diola=1;	
				h_diola=0;
			}
		        j=k;     
		        i=0;       //扫描完每张图像，让i归零
	        }
	        k++;      //每显示完一张图像，k自身加1
	        i=0;
	        if(k>32)   //如果扫描完第33张图像，k归零
		 {
	             k=0;   
		 }
	   j=k;    //让j等于k，让for语句接着进行下一张图片扫描
	}
}