#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uint Count = 0;
uchar code table[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void Time0_Init()
{
TMOD = 0x01;
TH0 = 0x4c;
TL0 = 0x00;
ET0 = 1;
EA = 1;
TR0 = 1;
}
void Time0_Int() interrupt 1
{
TH0 = 0x4c;
TL0 = 0x00;
Count++;
}
void main()
{
uchar i = 0;
Time0_Init();
P2 = 0xfe;
while(1)
{
P0 = table[i % 10];
if(Count == 20)
{
Count = 0;
i++;
}
}
} |