各位大佬,为什么按下k3时候没有反应,如果把前面删了k3就可以正常使用,求大佬能指点一下使用芯片stc89c52
#include <REGX52.H>
sbit k1=P3^3;
sbit k2=P3^4;
sbit k3=P3^5;
unsigned char table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
void Delay(unsigned char x)
{
while(x--)
{
unsigned char i, j;
i = 2;
j = 239;
do
{
while (--j);
} while (--i);
}
}
void nixie (unsigned char wei,unsigned char num)
{
switch(wei)
{
case 1:P2_0=0;P2_1=1;P2_2=1;P2_3=1;
P0=table[num];
break;
case 2:P2_0=1;P2_1=0;P2_2=1;P2_3=1;
P0=table[num];
break;
case 3:P2_0=1;P2_1=1;P2_2=0;P2_3=1;
P0=table[num];
break;
case 4:P2_0=1;P2_1=1;P2_2=1;P2_3=0;
P0=table[num];
break;
}
}
void main()
{
while(1)
{
if(k1==0)
{
Delay(50);
if(k1==0)
{
nixie(1,6);
Delay(500);
nixie(2,6);
Delay(500);
nixie(3,6);
Delay(500);
nixie(4,6);
Delay(500);
}
}
if(k2==0)
{
nixie(1,8);
Delay(500);
nixie(2,8);
Delay(500);
nixie(3,8);
Delay(500);
nixie(4,8);
Delay(500);
}
while(k2==0);
}
if(k3==0)
{
Delay(50);
if(k3==0)
{
nixie(1,1);
Delay(5);
nixie(2,2);
Delay(5);
nixie(3,3);
Delay(5);
nixie(4,4);
Delay(5);
}
}
}
|