资源描述:
《钟优福51单片机计算器程序及仿真图》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、u‘:e/[2y门fkM5*e>56key67key?aXTAL1XTAL2RSTPOO/ADOP01/AD1P02/AD2PO3/AD3P04/AD4P05/AD5P0B/AD6PO7/AD7r2U/AoP21/A9p^FALEEAP22/A10DCOC44rxrjoJywt
2、Pi.7P3.7f123P2224P2326P2426P2S27:P26?8P27i)intT1314157we<3MyQkOYlT2keyjAHCDEFGDP1234kev4key5bev6■er?程序如下:#include#defineDisP2#definekeyPlsbitweil=P3A4;sbitwei2=P3A5;sbitwei3=P3A6;sbitwei4=P3A7;sbitJS=P3A1;bitIS_Check=O;bitISJisuan=O;uns
3、ignedintData=O,jishu=O;unsignedcharanjian[l0]=n0n,xiaoshu=0;codeunsignedcharDData[]={voidvoidvoidvoidcodeunsignedcodeunsignedCheckkey(void);Display(unsignedcharcharintdelay(unsignedcharjisuan(void);main()EXO=1;ITO=O;EX1=1;IT1=O;EA=1;0x3f,0x06,0x5b,0x4f,0
4、x66,0x6d,0x7d,0x07,0x7f,0x6f,};DDatal[]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0x览Oxef,};table[4][4]={,l,;2,;3,;+DisData);delaydata);key=OxOf;//判断键盘while(l){key=OxOf;〃判断键盘if(IS_Check==l){IS_Check=O;Checkkey();}if(IS_jisuan==l){IS_Jisuan=O;jisuan();}Di
5、splay(Data);}}voidinter_0(void)interrupt0{EA=0;IS_Check=1;}voidinter_l(void)interrupt2{EA=0;JS=1;IS」isuan=l;voidCheckkey(void)unsignedcharlie=0,hang=0;unsignedcharz=10;if(key!=0x0f)delay(50);if(key!=0x0f)switch(key){case0x0e:lie=0;break;caseOxOd:lie=l;br
6、eak;case0x0b:lie=2;break;default:lie=3;break;key=0xf0;switch(key)caseOxeO:hang=O;break;caseOxdO:hang=l;break;case0xb0:hang=2;break;default:hang=3;break;if(table[hang][lie]==,=,){anjian[jishu]=O;Data=O;jishu=O;EA=1;JS=O;}if(table[hang][lie]==,<,){jishu=O;
7、Data=O;xiaoshu=0;anjian[0]=0;anjian[l]=0;anjian[2]=0;anjian[3]=0;anjian[4]=0;anjian[5]=0;anjian[6]=0;anjian[7]=0;anjian[8]=0;anjian[9]=0;}if((table[hang][lie]!=V)&&(table[hang][lie]!='+')&&(table[hang][lie]!=-')&&(table[hang][lie]!='*')&&(table[hang][lie
8、]!=7,)&&(table[hang][lie]!='='))Data=(Data*10)+(table[hang][lie]-48);elseData=O;if((table[hang][lie]!='v')&&(table[hang][lie]!==*))anjian[jishu++]=table[hang][lie];}}key=OxOf;while(z—)Display(Data);EA=1;}voidDisplay(unsign