#include<reg52.h>
#define uchar unsigned char
#define uint  unsigned int
uchar code table[4] = {0xC0,0xF9,0xA4,0xB0}; //段选
uchar code table1[4]={0x01,0x02,0x04,0x08};	//位选
void Delay(uint i)
{
	uchar x,j;
	for(j=0;j<i;j++)
	for(x=0;x<=148;x++);	
}
 void Main(void)
{
	uchar i;
	while(1)
	{
		for(i=0;i<4;i++)
		{	
			P2= table1[i];	 //选择哪一位数码管点亮
			P0 = table[i];	 //赋值段码给P0口
			Delay(2);	 //延时0.02秒
		}
	}
}
