单片机的P34、P35、 P36 、P37 口分别接LED1、LED2、LED3、LED4,输出低电平点亮LED灯, P32口接按键K1,按键按下时单片机输入低电平,程序如下: #include unsigned char key = 0; void main(void ) { char map0[4] = { 0x7f, 0xbf, 0xdf,0xef }; //LED 状态数据 char map1[2] = { 0x3f, 0xcf }; //LED 状态数据 unsigned char i = 0; int j = 0; IT0 = 1; EX0 = 1; EA = 1; while (1 ) { i ++; switch (key ) { case 0: {P3 = map0[i % 4 ]; break;} case 1: {P3 = map1[i % 2 ]; break; } } for (j = 0; j < 0x4000; j ++ ); } } void int0(void ) interrupt 0 using 0 { key ++; if(key==2)key=0; }