缘由https://bbs.csdn.net/topics/396573224 示例工程下载
#include "reg52.h"
sbit K1 = P1^4;//按键
sbit K2=P1^5;//按键
sbit K3=P1^6;//按键
sbit K4=P1^7;//按键
bit k1=0,k2=0,k3=0,k4=0,k=0;//标记
unsigned char code LedBiao[] = {0,15,240,85,170};//前4后4奇数偶数
void main()
{
unsigned char Xd=0;
unsigned int Ys=47474;
while(1)
{
if(!K1&&!--Xd){k1=~k1;k2=k3=k4=0;while(!K1);}
if(!K2&&!--Xd){k2=~k2;k1=k3=k4=0;while(!K2);}
if(!K3&&!--Xd){k3=~k3;k2=k1=k4=0;while(!K3);}
if(!K4&&!--Xd){k4=~k4;k2=k3=k1=0;while(!K4);}
if(--Ys==0)
{
k=~k;if(!k) P2=0;else P2=255;Ys=47474;
if(k&&k1)P2=LedBiao[1];
if(k&&k2)P2=LedBiao[2];
if(k&&k3)P2=LedBiao[3];
if(k&&k4)P2=LedBiao[4];
}
}
}