试下这样改#include <REG52.h> #define DY_PORT P0 sbit DY_KEY = P3 ^ 2; unsigned char table[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};void delay (unsigned int a){ unsigned int i; while( --a != 0){ for(i = 0; i < 600; i++); } }void main(void){ unsigned char c,b; DY_KEY = 1; DY_PORT = 0xff; while(1){ for(b=0;b<8;b++) { if(DY_KEY == 0){ delay(20); if(DY_KEY == 0){ c++; if(c==8) { c=0; } DY_PORT = table[c]; while(DY_KEY == 0); } } } }}