#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
#define duan P0
#define wei P1
//----------------------------------------------------------------------------
uchar code weima[8] = {//位选控制查表的方法控制
0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar code duanma[17] = {//0、1、2、3、4、5、6、7、8、9、A、b、C、d、E、F的显示码
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
//----------------------------------------------------------------------------
void delay(uchar x)//延时函数的定义
{
uchar y=110,z;
for(z=x;z>=0;z--)
for(y;y>=0;y--);
}
//----------------------------------------------------------------------------
void main()//主函数
{
while(1)
{
duan=weima[0];
wei=duanma[0];
delay(500);
duan=0x00;
duan=weima[1];
wei=duanma[1];
delay(500);
duan=0x00;
duan=weima[2];
wei=duanma[2];
delay(500);
duan=0x00;
duan=weima[3];
wei=duanma[3];
delay(500);
duan=0x00;
duan=weima[4];
wei=duanma[4];
delay(500);
duan=0x00;
duan=weima[5];
wei=duanma[5];
delay(500);
duan=0x00;
duan=weima[6];
wei=duanma[6];
delay(500);
duan=0x00;
duan=weima[7];
wei=duanma[7];
delay(500);
duan=0x00;
}
}