基于51單片機的計算器 C語言程序 作者: 時間:2016-11-25 來源:網(wǎng)絡(luò) 加入技術(shù)交流群 掃碼加入和技術(shù)大咖面對面交流海量資料庫查詢 收藏 void ChangeNum(uchar *p,uchar nCount){ if(nCount<4) { uchar ncount; ncount=nCount; while(ncount>0) { *(p+nCount)=*(p+nCount-1); ncount--; } }}void Delay_510(void)//延時510微秒{#pragma asmMOV R0,#7DHMOV R1,#02HTSR1:DJNZ R0,TSR1MOV R0,#7DHDJNZ R1,TSR1#pragma endasm}void Time0_Isr_Int(void) interrupt 1 //定時器0中斷服務(wù)子程序{ TH0=(65536-20000)/256; TL0=(65536-20000)%256; P1=0xF0; if((P1&0xF0)!=0xF0) { Delay_510(); if((P1&0xF0)!=0xF0) { P1=0xFE; if((P1&0xF0)==0xE0)//數(shù)字鍵0 { KeyNum=0;ChangeNum(NumBufe,KeyPos);KeyPos++; } if((P1&0xF0)==0xD0) { KeyNum=1;ChangeNum(NumBufe,KeyPos);KeyPos++; } if((P1&0xF0)==0xB0) { KeyNum=2; ChangeNum(NumBufe,KeyPos); KeyPos++;} if((P1&0xF0)==0x70) { KeyNum=3; ChangeNum(NumBufe,KeyPos);KeyPos++; } P1=0xFD; if((P1&0xF0)==0xE0) { KeyNum=4;ChangeNum(NumBufe,KeyPos);KeyPos++; } if((P1&0xF0)==0xD0) { KeyNum=5; ChangeNum(NumBufe,KeyPos);KeyPos++; } if((P1&0xF0)==0xB0) { KeyNum=6; ChangeNum(NumBufe,KeyPos);KeyPos++; } if((P1&0xF0)==0x70) { KeyNum=7; ChangeNum(NumBufe,KeyPos);KeyPos++; } P1=0xFB; if((P1&0xF0)==0xE0) { KeyNum=8; ChangeNum(NumBufe,KeyPos);KeyPos++; } if((P1&0xF0)==0xD0) { KeyNum=9; ChangeNum(NumBufe,KeyPos);KeyPos++; } if((P1&0xF0)==0xB0)//加法 { op=1; add=1; } if((P1&0xF0)==0x70) { op=1; dec=1; } P1=0xF7; if((P1&0xF0)==0xE0) { op=1; mul=1; } if((P1&0xF0)==0xD0) { op=1; div=1; } if((P1&0xF0)==0xB0)//等號 { equ=1; } if((P1&0xF0)==0x70)//清零 { clr=1; } } }}本文引用地址:http://butianyuan.cn/article/201611/321399.htm 上一頁 1 2 下一頁
評論