|
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar code tab[10]={
0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f};
uint c=0,e=0,w=10,q=1,p=0;
sbit led=P3^0;
void doudelay(uint i)
{
uint j;
while(--i)
for(j=0;j<120;j++)
;
}
void xianshi()
{
led=q%2;
P0=0xfe;
P1=tab[c/10];
doudelay(20);
P0=0xfd;
P1=tab[c%10];
doudelay(20);
}
void xianshi1()
{
led=q%2;
P0=0xfe;
P1=tab[c/10];
doudelay(10);
P0=0xfd;
P1=tab[c%10];
doudelay(10);
}
void main()
{
P1=0x00;
IE=0x85;
TCON=0x00;
IP=0x04;
while(1)
{
xianshi();
}
}
void int0() interrupt 0
{
doudelay(1);
while(e<99)
{
c=e;
c++;
e=c;
xianshi();
doudelay(15);
}
c=0;
e=0;
}
void int1() interrupt 2
{
EA=0;
doudelay(1);
while(w<=20)
{
while(p<10)
{
p++;
xianshi1();
}
p=0;
q++;
w++;
}
w=0;
q=1;
EA=1;
}
|
|