#include<reg51.h>unsignedchark;sbitK1=P0^0;sbitK2=P0^1;sbitLED=P1^1;unsignedcharSZ[]={3,5,7,9,11,13,15}delay1s()
;voidmain(){while(1){if(K1==0){LED=0,TR1=1};delay1s();LED=1;}}delay1s(){while(LED=0){for(i=0;i<k;i++){TMOD=0x10;TH1=0x3c;TL1=0xb0;while(!TF1);TF1=0;}}}思路僅供參考。