______________________________________ 功能:通過按鍵,控制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]; }