仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
單片機源程序如下:
- //-----------------------------------------------------------------
- // 名稱:用8051+1601LCD設計的整型計算器
- //-----------------------------------------------------------------
- // 說明: 本例由LABCENTER ELECTRONICS公司提供,原始程序由C與匯編混合
- // 編寫,本例將所有代碼全部改編成了C程序代碼并簡化了設計.
- //
- //-----------------------------------------------------------------
- #include <reg51.h>
- #include <intrins.h>
- #include <ctype.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include "calc.h"
- #define INT8U unsigned char
- #define INT16U unsigned int
- static long a,b; //當前運算符的前后兩個操作數
- static char CurrKeyChar; //當前按鍵字符
- static char Last_OP; //最近輸入的操作符
- static char Last_Char; //所輸入的前一字符
- static char result; //當前運算的結果狀態
- //顯示緩沖,數字輸入緩沖及數字輸入緩沖區索引定義
- static char xdata outputbuffer[MAX_DISPLAY_CHAR+1];
- static char xdata NumberStr[MAX_DISPLAY_CHAR+1];
- static char xdata NumberIdx;
- //-----------------------------------------------------------------
- // 檢查待顯示數據是否越界
- //-----------------------------------------------------------------
- int calc_chkerror(long num) { return labs(num) <= 9999999? OK : ERROR;}
- //-----------------------------------------------------------------
- // 主程序
- //-----------------------------------------------------------------
- void main()
- {
- }
- //-----------------------------------------------------------------
- // 根據運算符按鍵進行運算處理
- //-----------------------------------------------------------------
- void Operator_Process(char OP)
- {
- }
復制代碼
所有資料51hei提供下載:
用8051 1601LCD設計的整型計算器.zip
(29.95 KB, 下載次數: 26)
2019-3-13 19:28 上傳
點擊文件名下載附件
|