#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
uchar code LEDDis[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,
0x80,0x90};//數(shù)碼管段碼表
uint t=0,num=0;
void main()
{
TMOD=0x01;//設(shè)置定時器0為工作方式1
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;//總中斷打開
ET0=1;//開定時器中斷
TR0=1;//定時器打開
while(1)
{
if(t==20)//1s
{
t=0;
num++;
if(num==10)
{num=0;}
P0=LEDDis[num];
P2=1;
}
}
}
void zhongduan() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
t++;
}