满意答案
闂垫嵎涓嶈触
2014.08.25
采纳率:54% 等级:8
已帮助:363人
#include unsigned char Get_Key;unsigned char Dis[4]={0xff,0xff,0xff,0xff}; unsigned char Seg;unsigned char Delay;unsigned int Conut;unsigned char code disp_code[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
void scanf(void){unsigned char recode,j;P1=~(0x01<>4; //读取列 if(recode<0x0f) //判断是否有键按下 { if(++Delay>2) Delay=3; if(Delay==2) //延时去抖动 16ms { if(Conut==0) { Dis[0]=Dis[1]=Dis[2]=Dis[3]=0xff; } Conut=1000; for(j=0;j<4;j++){if(!(recode&0x01<
void InitTimer0(void) //2ms{ TMOD = 0x01; TH0 = 0xF8; TL0 = 0x30; EA = 1; ET0 = 1; TR0 = 1;}
void getdec(void){unsigned char i;unsigned int temp; for(i=0;i<4;i++) { if(Dis[3]==0xff) { Dis[3]=Dis[2]; Dis[2]=Dis[1]; Dis[1]=Dis[0]; Dis[0]=0; } } temp=Dis[3]+Dis[2]*16+Dis[1]*256+Dis[0]*4096; Dis[0]=temp/1000; Dis[1]=temp%1000/100; Dis[2]=temp%100/10; Dis[3]=temp%10; for(i=0;i<4;i++) { if(Dis[i]==0) Dis[i]=0xff; else break; }}
void Timer0Interrupt(void) interrupt 1{ TH0 = 0xF8; TL0 = 0x30; Seg=(++Seg)&0x03; P3=0x01<
main(void){unsigned char i;InitTimer0(); while(1) { if(Get_Key) { for(i=3;i>0;i--) //显示数据移动 { Dis[i]=Dis[i-1]; } Dis[0]=Get_Key-1; Get_Key=0; } }}
00分享举报