#include <REGX51.H>
#define aled1 P1_0
#define aled2 P1_1
#define aled3 P1_2
#define aled4 P1_3
unsigned char i,k;
unsigned char code maled[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x9 0};
void delay()
{
TMOD=0x01; //timer0 16 byt
TH0=0x2710;
TL0=0x2710;
while(!TF0)
TF0=0;
TR0=0;
}
void ngatngoai0()interrupt 0
{
while(1)
{
for(k=0;k<9999;k++)
{
P2=maled[i/1000];
aled1=0;
delay();
aled1=1;
P2=maled[(i/100)%10];
aled2=0;
delay();
aled2=1;
P2=maled[(i/10)%10];
aled3=0;
delay();
aled3=1;
P2=maled[i%10];
aled4=0;
delay();
aled4=1;
}
}
}
void khoitaongatngoai0()
{EA=1;
EX0=1;
IT0=1;
}
void main()
{khoitaongatngoai0();
}
#define aled1 P1_0
#define aled2 P1_1
#define aled3 P1_2
#define aled4 P1_3
unsigned char i,k;
unsigned char code maled[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x9 0};
void delay()
{
TMOD=0x01; //timer0 16 byt
TH0=0x2710;
TL0=0x2710;
while(!TF0)
TF0=0;
TR0=0;
}
void ngatngoai0()interrupt 0
{
while(1)
{
for(k=0;k<9999;k++)
{
P2=maled[i/1000];
aled1=0;
delay();
aled1=1;
P2=maled[(i/100)%10];
aled2=0;
delay();
aled2=1;
P2=maled[(i/10)%10];
aled3=0;
delay();
aled3=1;
P2=maled[i%10];
aled4=0;
delay();
aled4=1;
}
}
}
void khoitaongatngoai0()
{EA=1;
EX0=1;
IT0=1;
}
void main()
{khoitaongatngoai0();
}
Comment