#include <reg52.h>
sbit P33=P3^3;
unsigned char code Tab[] = { 0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xff };
unsigned long int x;
void delay1ms(unsigned int i)
{
unsigned char j;
while(i--)
{
for (j=0;j<115;j++)//1ms基准廷时
{
;
}
}
}
void Display(unsigned long int x)
{
P1=0xf7;
P0=0xff;
P0=Tab[x%10];
delay1ms(1);
P1=0xfb;
P0=0xff;
P0=Tab[x/10%10];
delay1ms(1);
P1=0xfd;
P0=0xff;
P0=Tab[x/100%10];
delay1ms(1);
P1=0xfe;
P0=0xff;
P0=Tab[x/1000%10];
delay1ms(1);
}
void main(void)
{
EA=1;
EX1=1;
IT1=1;//INT1
while (1) /
{
Display(x);
}
}
void Key_counter()interrupt 2
{
if(P33==0){
delay1ms(5);
if(P33==0){
x=(x+1)%10000;
}
}
} |