#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
char num,p=0;
uchar table[]={0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f};
void delay(uint m)
{
uint i,j;
for(i=110;i>0;i--)
for(j=m;j>0;j--);
}
void main()
{
P2=0x3f;
TMOD=0x01;
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
ET0=1;
EA=1;
TR0=1;
while(1)
{
if(num==20)
{
num=0;
p++;
P2=table[p];
if(p>=10)
p=-1;
}
}
}
void timer0() interrupt 1
{
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
num++;
} |