按K3键为功能时,时数码管要闪,分数码管要闪,
定时程序怎么写
#include
#include
#define uchar unsigned char
#define uint unsigned int
uchar gonneng,gonneng1,gonneng2,a,b,h,g,s,b,q,w,sw,p;
uint shu1;
uchar code shu[10]={0x3f,0x06,0x5b,
0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
sbit k0=P3^2;
sbit k=P3^4;
sbit k1=P3^5;
sbit k2=P3^6;
sbit k3=P3^7;
sbit we=P2^7;
sbit du=P2^6;
sbit dun=P1^0;
sbit dun1=P1^1;
sbit dun2=P1^2;
shi(uint o)
{
uint w,q;
for(w=o;w>0;w--)
for(q=25;q>0;q--);
}
void zong()
{
if(k1==0)h++;if(h==3)h=0;
}
void deng(void)
{while(k1==0){{
uchar m;for(m=0;m<30;m++);}gonneng=1;gonneng1=0;gonneng2=0;dun=0;dun1=1;dun2=1;}
}
void deng1(void)
{while(k1==0){{
uchar m;for(m=0;m<30;m++);}gonneng=0;gonneng1=1;gonneng2=0;dun=1;dun1=0;dun2=1;}
}
void deng2(void)
{while(k1==0){{
uchar m;for(m=0;m<30;m++);}gonneng=0;gonneng1=0;gonneng2=1;dun=1;dun1=1;dun2=0;}
}
void ha()
{uint m;q++;for(m=0;m<30;m++);if(q==6)q=0;
}
void ha1()
{uint m;w++;for(m=0;m<30;m++);if(w==10)w=0;
}
void ha2()
{uint m;sw++;for(m=0;m<30;m++);if(sw==3)sw=0;
if(sw!=2)p=1;else {if(w==4){w=0;sw=0;shu1=0;}}
}
void din();
void main()
{
k=0;
din();
while(1)
{
{if(k1==0)shi(19);if(k1==0)
{
if(k1==0)zong();if(k1==0)switch(h)
{
case 0:deng2();break;
case 1:deng();break;
case 2:deng1();break;
}}
if(k1==1)shi(19);if(k1==1);k0=1;}
{if(k2==0)shi(19);if(k2==0)
{
if(gonneng==1)ha();
if(gonneng1==1)ha1();
if(gonneng2==1)ha2();}
if(k2==1)shi(19);if(k2==1);}
{
P0=0xff;
we=1;
we=0;
P0=shu[g];
du=1;
du=0;
P0=0xdf;
we=1;
we=0;
shi(13);
P0=0xff;
we=1;
we=0;
P0=shu[s];
du=1;
du=0;
P0=0xef;
we=1;
we=0;
shi(13);
P0=0xff;
we=1;
we=0;
P0=shu[b];
du=1;
du=0;
P0=0xf7;
we=1;
we=0;
shi(13);
P0=0xff;
we=1;
we=0;
P0=shu[q];
du=1;
du=0;
P0=0xfb;
we=1;
we=0;
shi(13);
P0=0xff;
we=1;
we=0;
P0=shu[w];
du=1;
du=0;
P0=0xfd;
we=1;
we=0;
shi(13);
P0=0xff;
we=1;
we=0;
P0=shu[sw];
du=1;
du=0;
P0=0xfe;
we=1;
we=0;
shi(1);
}
}
}
void din()
{
EA=1;
EX0=1;
IT0=1;
TR0=1;
ET0=1;
TMOD=0X01;
TH1=(65535-50000)/256;
TL1=(65535-50000)%256;
}
void din1() interrupt 1
{
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
a++;
if(a==20)
{
a=0;
shu1++;
g=shu1%10;
s=shu1%100/10;
if(s==6){shu1=0;b++;s=0;}
if(b==10){shu1=0;q++;b=0;}
if(q==6){shu1=0;w++;q=0;}
if(w==10){shu1=0;sw++;w=0;}
if(sw==3){shu1=0;sw=0;}
if(sw!=2)p=1;else{if(w==4){sw=0;w=0;}}
}
}