单片机的P34、P35、P36、P37口分别接LED1、LED2、LED3、LED4,输出低电平点亮LED灯, P32口接按键K1,按键按下时单片机输入低电平,程序如下: #include "reg51.h" unsigned char a; void main() { TMOD=0x01; TH0=0xee; TL0=0x00; EA=1; ET0=1; TR0=1; EX0=1; IT0=1; while(1); } void int0()interrupt 0 { TR0=!TR0; } void t0( )interrupt 1 { static unsigned char count=0,Bit=0; TH0=0xee; TL0=0x00; count++; if(count>=200) { count=0; Bit++; if(Bit==16) Bit=0; a=Bit; a=~a; a=a<<4 |0x0f; P3=a; } }