1、没有消除抖动的原始代码: #include <REGX52.H>
#include <intrins.h>
sbit KeyValue=P3^7;
unsigned char code segment[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
//定义数码管显示0~9
void main(){
static char count=1;
P2=segment[0]; //开始运行显示0
while(1){
if(KeyValue==0){
P2=segment[count];
count++;
if(count>=10){ //超过0~9,数码管显示回到0
count=0;
}
}
}
}
|