智利足球吧 关注:3,535贴子:14,113
  • 4回复贴,共1
ejejeje


IP属地:江苏来自iPhone客户端1楼2024-05-06 14:11回复
    #include <reg51.h>sbit lie0=P1^0;sbit lie1=P1^1;sbit lie2=P1^2;sbit hang0=P1^3;sbit hang1=P1^4;sbit hang2=P1^5;void delay(){unsigned char i;for(i=0;i<255;i++);}void main(){while(1){delay();hang0=0;hang1=1;hang2=1;if(lie0==0){P0=0;}if(lie1==0){P0=1;}if(lie2==0){P0=2;}hang0=1;hang1=0;hang2=1;if(lie0==0){P0=3;}if(lie1==0){P0=4;}if(lie2==0){P0=5;}hang0=1;hang1=1;hang2=0;if(lie0==0){P0=6;}if(lie1==0){P0=7;}if(lie2==0){P0=8;}}}


    IP属地:江苏来自iPhone客户端2楼2024-05-06 14:11
    回复
      #include <reg51.h>void int0() interrupt 0{unsigned char temp;temp=P1&0x0f;P2=temp;}void main(){IT0=1;EX0=1;EA=1;while(1){}


      IP属地:江苏来自iPhone客户端3楼2024-05-06 14:23
      回复
        #include <reg51.h>sbit p1_0=P1^0;sbit p1_2=P1^2;sbit p1_3=P1^3;unsigned char jianma;void delay(){unsigned char i,j,k;for(i=0;i<255;i++){/*for(j=0;j<255;j++){for(k=0;k<20;k++);}*/}}void findkey(unsigned char p1)//获得键码{unsigned char temp;p1=p1&0xf0;//判断是哪根线低电平switch(p1){case 0xe0:temp=~P1;temp=temp&0x0f;P0=temp;switch(temp){case 0x01:jianma=1;break;case 0x02:jianma=2;break;case 0x04:jianma=3;break;case 0x08:jianma=4;break;default:break;}break;case 0xd0:temp=~P1;temp=temp&0x0f;switch(temp){case 0x01:jianma=1+4;break;case 0x02:jianma=2+4;break;case 0x04:jianma=3+4;break;case 0x08:jianma=4+4;break;default:break;}break;case 0xb0:temp=~P1;temp=temp&0x0f;switch(temp){case 0x01:jianma=1+8;break;case 0x02:jianma=2+8;break;case 0x04:jianma=3+8;break;case 0x08:jianma=4+8;break;default:break;}break;case 0x70:temp=~P1;temp=temp&0x0f;switch(temp){case 0x01:jianma=1+12;break;case 0x02:jianma=2+12;break;case 0x04:jianma=3+12;break;case 0x08:jianma=4+12;break;default:break;}break;default:break;}}void ke


        IP属地:江苏来自iPhone客户端4楼2024-05-06 14:23
        回复
          void keyprocess()//不同按键对应不同处理过程{P0=jianma;}void int0() interrupt 0{delay();//去抖动P1=0xef;//1110 1111findkey(P1);keyprocess();P1=0xdf;//1101 1111findkey(P1);keyprocess();P1=0xbf;//1011 1111findkey(P1);keyprocess();P1=0x7f;//0111 1111findkey(P1);keyprocess();P1=0x0f;//0000 1111}void main(){P1=0x0f;jianma=0;IT0=1;EX0=1;EA=1;while(1){}}


          IP属地:江苏来自iPhone客户端5楼2024-05-06 14:23
          回复