欢迎来到天天文库
浏览记录
ID:16498857
大小:144.00 KB
页数:3页
时间:2018-08-10
《中断扫描矩阵键盘89c51》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、/*自动1231班31号唐继*/#includeunsignedchartable[]={0x7c,0x06,0x66,0x7f,0x7d,0x5b,0x6d,0x07,0x39,0x5e,0x77,0x79,0x4f,0x6f,0x71,0x3f};voiddelay(unsignedchari){unsignedcharx,j;for(j=0;j2、g=0;scan=0xef;P1=0x0f;for(n=0;n<4;n++){P1=scan;temp=~P1;temp=temp&0x0f;col=n;flag=1;if(temp==0x01){rol=0;break;}elseif(temp==0x02){rol=1;break;}elseif(temp==0x04){rol=2;break;}elseif(temp==0x08){rol=3;break;}elseflag=0;scan=(scan<<1)+1;}if(flag==0)return-1;elsereturn(rol*4+co3、l);}voidscankeyled()interrupt2{unsignedchari,key;key=scankey();while(i!=-1){delay(20);i=scankey();}P2=0x00;delay(20);P0=table[key];P2=0x01;delay(20);}voidmain(){while(1){EA=1;EX1=1;IT1=0;P0=0xff;P1=0x0f;}}
2、g=0;scan=0xef;P1=0x0f;for(n=0;n<4;n++){P1=scan;temp=~P1;temp=temp&0x0f;col=n;flag=1;if(temp==0x01){rol=0;break;}elseif(temp==0x02){rol=1;break;}elseif(temp==0x04){rol=2;break;}elseif(temp==0x08){rol=3;break;}elseflag=0;scan=(scan<<1)+1;}if(flag==0)return-1;elsereturn(rol*4+co
3、l);}voidscankeyled()interrupt2{unsignedchari,key;key=scankey();while(i!=-1){delay(20);i=scankey();}P2=0x00;delay(20);P0=table[key];P2=0x01;delay(20);}voidmain(){while(1){EA=1;EX1=1;IT1=0;P0=0xff;P1=0x0f;}}
此文档下载收益归作者所有