1、/* 自动 1231 班 31 号唐继 */ #includeunsigned char table=0x7c,0x06,0x66,0x7f,0x7d,0x5b,0x6d,0x07,0x39,0x5e,0x77,0x79,0x4f,0x6f,0x71,0x3f; void delay(unsigned char i) unsigned char x,j;for(j=0;ji;j+)for(x=0;x248;x+);unsigned char scankey(void)unsigned char n,scan,col,rol,temp;bit flag=0;scan=0xef;P1=0x0f;f
2、or(n=0;n4;n+)P1=scan;temp=P1;temp=tempcol=n;flag=1;if(temp=0x01)rol=0;break;else if(temp=0x02)rol=1;break;else if(temp=0x04)rol=2;break;else if(temp=0x08)rol=3;break;elseflag=0;scan=(scan1)+1;if(flag=0)return -1;elsereturn(rol*4+col); void scankeyled()interrupt 2unsigned char i,key;key=scankey();while(i!=-1)delay(20);i=scankey();P2=0x00;delay(20);P0=tablekey;P2=0x01;delay(20);void main()while(1)EA=1;EX1=1;IT1=0;P0=0xff;P1=0x0f;