#include<reg52.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
uchar code table[]={ 0xc0,0xf9,0xa4,0xb0, //共陽數碼管段碼 0,1,2,3
0x99,0x92,0x82,0xf8, //共陽數碼管段碼 4,5,6,7
0x80,0x90 //共陽數碼管段碼 8,9,全滅,橫杠
};
uchar a,tt;
void main()
{
TMOD=1;
TH0=0xF8;
TL0=0xD9;
EA=1;
ET0=1;
TR0=1;
//P2=0x7f;
while(1)
{
if(tt==1)
{
tt=0;
a++;
if(a==10)
a=0;
P2=~(01<<a);
P0=table[a];
}
}
}
void timer0() interrupt 1
{
TH0=0xF8;
TL0=0xD9;
tt++;
}
|