缘由关于#c语言#的问题:只用c语言语句怎么实现51单片机动态显示0-99的数值-编程语言-CSDN问答
#include "REG52.h"
sbit K2 = P1^5;
sbit K3 = P1^6;
sbit K4 = P1^7;
unsigned char code smgduan[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07
,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};//0-9A-F
void smxs(unsigned char mz, unsigned char w)
{
unsigned char Xd=0;
P2=255;
P2=255-smgduan[mz];
P3=w;
while(++Xd);
}
void main()
{
unsigned char jz=0,zhi=0,wei=0,sy=0,k=0;
while(1)
{
smxs(jz%10,128);
smxs(jz/10,64);
if(!K4&&!++k){if(++jz>99)jz=0;while(!K4);}
else if(!K3&&!++k){if(--jz>99)jz=99;while(!K3);}
else if(!K2&&!++k){jz=0;while(!K2);}
}
}