请问出现这种一般是哪里出错了
下面是程序
那位大神帮帮忙运行修改一下
谢谢了
- #include<reg51.h>
- sbit k1=P1^0;
- sbit k2=P1^1;
- sbit k3=P1^2;
- sbit k4=P1^3;
- sbit k5=P1^4;
- sbit k6=P1^5;
- unsigned char DSY_CODE[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82};
- void delayms(unsigned int ms)
- {
- unsigned int i,j;
- for(i=0;i<ms;i++)
- for(j=0;j<1141;j++);
- }
- void main()
- {
- unsigned char key,i;
- TMOD=0x01;
- TH0=0xff;
- TL0=0xff;
-
- while(1)
- {
- key=P1;
- if(key==0xff)
- {
- for(i=1;i<7;i++)
- {
- switch(i)
- {
- case 1:P2=0x01;break;
- case 2:P2=0x02;break;
- case 3:P2=0x04;break;
- case 4:P2=0x08;break;
- case 5:P2=0x10;break;
- case 6:P2=0x20;break;
- default : P2=0x01;break;
- }
- P0=DSY_CODE[i];
- delayms(10);
- }
- }
- if(key!=0xff)
- {EA=1;
- ET0=1;
- TR0=1;
- }
- }
- }
-
- void Tim_T0() interrupt 1 using 0
- {
- if(k1==0&&k2!=0&&k3!=0&&k4!=0&&k5!=0&&k6!=0)
- {
- P2=0xff;
- P0=DSY_CODE[1];
- }
- if(k2==0&&k1!=0&&k3!=0&&k4!=0&&k5!=0&&k6!=0)
- {
- P2=0xff;
- P0=DSY_CODE[2];
- }
-
- if(k3==0&&k1!=0&&k2!=0&&k4!=0&&k5!=0&&k6!=0)
- {
- P2=0xff;
- P0=DSY_CODE[3];
- }
- if(k4==0&&k1!=0&&k2!=0&&k3!=0&&k5!=0&&k6!=0)
- {
- P2=0xff;
- P0=DSY_CODE[4];
- }
- if(k1!=0&&k6!=0&&k2!=0&&k3!=0&&k4!=0&&k5==0)
- {
- P2=0xff;
- P0=DSY_CODE[5];
-
- }
- if (k6==0&&k1!=0&&k2!=0&&k3!=0&&k4!=0&&k5!=0)
- {
- P2=0xff;
- P0=DSY_CODE[6];
- }
- }
复制代码
|