回复 2楼 chenliangjs
#include <reg51.h>
#include <stdio.h>
#define uchar
unsigned char
#define uint
unsigned int
uchar h;
uint r=0;
uint s;
uchar code
dis[]={
0Xc0,/*0*/
0Xf9,/*1*/
0Xa4,/*2*/
0Xb0,/*3*/
0X99,/*4*/
0X92,/*5*/
0X82,/*6*/
0Xf8,/*7*/
0X80,/*8*/
0X90,/*9*/
0Xff,/*NULL*/
};
void delay(uint c)
{
uint i,j;
for(i=0;i<c;i++)
for(j=0;j<100;j++);
}
//interrupt 1
void t0(void) interrupt 0 using 1
{
delay(2);
if(INT0==0)
{
r++;
if(r==2)
{
r=0;
}
r%=2;
if(r==0)
{
P0=0xeb;
P1=0x00;
P2=0xff;
}while(1)
{
if(INT0==0|INT1==0|T0==0)
{
delay(2);
if(INT0==0|INT1==0|T0==0)
break;
}
};
}
}
//interrupt 2
void t1(void) interrupt 2 using 1
{
delay(2);
if(INT1==0)
{
r++;
if(r==2)
{
r=0;
}
r%=2;
if(r==0)
{
P0=0xdd;
P1=0x00;
P2=0xff;
}while(1)
{
if(INT1==0|INT0==0|T0==0)
{
delay(2);
if(INT1==0|INT0==0|T0==0)
break;
}
};
}
}
//interrupt 3
void t2(void) interrupt 1 using 1
{
TH0=0xff;
TL0=0xff;
delay(2);
if(T0==0)
{
P0=0xdb;
P1=0x00;
P2=0xff;
}while(1)
{
if(INT0==0|INT1==0)
{
delay(2);
if(INT0==0|INT1==0)
break;
}
};
}
void main(void)
{
TMOD=0x06;
TH0=0xff;
TL0=0xff;
TR0=1;
EA=1;
EX0=1;
EX1=1;
ET0=1;
while(1)
{
P0=0xeb;
for(h=28;h>0;h--)
{
for(s=248;s>0;s--)
{
P1=0x00;
P2=0xff;
P1=0x01;
P2=dis[h/10];
delay(1);
P1=0x00;
P2=0xff;
P1=0x02;
P2=dis[h%10];
delay(1);
P1=0x00;
P2=0xff;
P1=0x04;
P2=dis[(h+2)/10];
delay(1);
P1=0x00;
P2=0xff;
P1=0x08;
P2=dis[(h+2)%10];
delay(1);
}
}
delay(248);
P0=0xf3;
for(h=3;h>0;h--)
{
delay(392);
P0=0xf3;
delay(1);
P1=0x00;
P2=0xff;
P1=0xaa;
P2=dis[(h-1)%10];
delay(600);
P0=0xfb;
}
delay(248);
P0=0xdd;
for(h=38;h>0;h--)
{
for(s=248;s>0;s--)
{
P1=0x00;
P2=0xff;
P1=0x01;
P2=dis[(h+2)/10];
delay(1);
P1=0x00;
P2=0xff;
P1=0x02;
P2=dis[(h+2)%10];
delay(1);
P1=0x00;
P2=0xff;
P1=0x04;
P2=dis[h/10];
delay(1);
P1=0x00;
P2=0xff;
P1=0x08;
P2=dis[h%10];
delay(1);
}
}
delay(248);
P0=0xde;
for(h=3;h>0;h--)
{
delay(392);
P0=0xde;
delay(1);
P1=0x00;
P2=0xff;
P1=0xaa;
P2=dis[(h-1)%10];
delay(600);
P0=0xdf;
}
delay(248);
}
}
这个就是全贴,麻烦看一下哈,谢谢哦