______________________________________ 功能:通过按键,控制2位数码管100内计数 时间:2010—7—18 ______________________________________ #include<reg52.h> code unsigned char tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; unsigned char Dis_Shiwei; unsigned char Dis_Gewei; void delay(unsigned int cnt) { while(--cnt); } main() { EA=1; EX0=1; //外部中断0开 IT0=1; //边沿触发 while(1) { P0=Dis_Shiwei; P2=0; delay(300); P0=Dis_Gewei; P2=1; delay(300); } } void INT0_ISR(void) interrupt 0 using 1 //外部中断函数 { static unsigned char second; second++; if(second==100) second=0; Dis_Shiwei=tab[second/10]; Dis_Gewei=tab[second%10]; }