基于ats的矩阵键盘(matrix keyboard based on ats)

基于ats的矩阵键盘(matrix keyboard based on ats)

ID:13506833

大小:34.00 KB

页数:12页

时间:2018-07-23

基于ats的矩阵键盘(matrix keyboard based on ats)_第1页
基于ats的矩阵键盘(matrix keyboard based on ats)_第2页
基于ats的矩阵键盘(matrix keyboard based on ats)_第3页
基于ats的矩阵键盘(matrix keyboard based on ats)_第4页
基于ats的矩阵键盘(matrix keyboard based on ats)_第5页
资源描述:

《基于ats的矩阵键盘(matrix keyboard based on ats)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、基于at89s52的矩阵键盘(MatrixkeyboardbasedonAT89S52)/******************************************Function:matrixkeyboard(pressthecorrespondingbutton,digitaltubefrom0~Fdisplay)Singlechipmicrocomputer:AT89S52******************************************/#include#defineuintunsignedint#defineuchar

2、unsignedcharSbitDAT=P0^3;SbitCLK=P0^2;Uchar,temp,h;Voiddelay(uint);//delayproceduresVoidsendbyte(uchar);//digitaldisplayVoid(keyscan);//keyscanUcharcodetab[]={0xed,0x09,0xbc,0x9d,0x59,0xd5,0xf5,0x0d,0xfd,0xdd,0x7d,0xf1,0xe4,0xb9,0xf4,0x74,0x00},//0-F,totaleliminationVoidmain(void){Sendbyte

3、(16);//initialdigitaltubedisplayWhile(1){(keyscan);//keyscan}}Voiddelay(uintz){Uint,x,y;For(x=z;x>0;x--)For(y=100;y>0;y--);}Voidsendbyte(ucharbyte){Uchar,num,c;Num=tab[byte];For(c=0;c<8;c++){CLK=0;DAT=num&0x01;CLK=1;Num>>=1;//rightshiftassignment}}Void,keyscan(){Thefirstlineofthekeyscan/*P

4、2=0xfe;//determinethefirstlineofthekeyiseffectiveTemp=P2;//assignittoavariable(I/Oport,thefirstgeneralassignmenttoavariable,andthenthroughtheprocessingvariablestohandletheI/Oport)Temp=temp&0xf0;//forwhichthefirstlineofthepressbuttondetectionWhile(temp!=0xf0)/*thispartaslongasisusedtoelimin

5、atethejitter/press{Delay(5);Temp=P2;Temp=temp&0xf0;While(temp!=0xf0)//thisplacehasbeeneliminated,pressthejitter,P2valueshavebeendetermined{Temp=P2;//P2portvalueassignedtothevariableSwitch(Temp)//theswitchstatementisusedtodeterminewhichbuttonispressed,thedigitaltubedisplayvalue{Case0x7e:h=0

6、;Breakbreak;//thisisveryimportant,ifthereisamatchingvalue,jumpoutoftheswitchstatement,topreventtheprogramjumpout.Case0xbe:h=1;Break;Case0xde:h=2;Break;Case0xee:h=3;Break;Default:h=16;Break;}While(temp!=0xf0)/*thispartaslongasisusedtoeliminatethereleasejitter.{Temp=P2;Temp=temp&0xf0;}Sendby

7、te(H);//tothedigitaltubedisplay}}Secondrowsofkeys/*scanP2=0xfd;Temp=P2;Temp=temp&0xf0;While(temp,=0xf0){Delay(5);Temp=P2;Temp=temp&0xf0;While(temp,=0xf0){Temp=P2;switch(temp){case0x7d:h=4;break;case0xbd:h=5;break;case0xdd:h=6;break;case0xed:h=7;break;default:h

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。