51单片机简易计算器代码

#include"reg52.h"

#define uchar unsigned char #define uint unsigned int

sbit busy=P0^7; void delay(uint z) {

uint x,y;

for(x=z;x>0;x--) for(y=110;y>0;y--); }

char i,j,temp,num;

long a,b,c; //a,第一个数 b,第二个数 c,得数

uchar flag,fuhao;//flag表示是否有符号键按下,fuhao表征按下的是哪个符号 uchar code table[]={7,8,9,0,4,5,6,0,1,2,3,0,0,0,0,0}; uchar code

table1[]={7,8,9,0x2f-0x30,4,5,6,0x2a-0x30,1,2,3,0x2d-0x30,0x01-0x30,0,0x3d-0x30,0x2b-0x30}; //按键显示编码表

sbit lcden=P2^2; sbit lcdwrite=P2^1; sbit lcdrs=P2^0; //lcd的写指令

void write_com(uchar com) { lcdrs=0; lcden=0; P0=com; delay(1); lcden=1; delay(1); lcden=0; }

//lcd的写数据

void write_date(uchar da) { lcdrs=1; lcden=0; P0=da; delay(1); lcden=1; delay(1); lcden=0; }

//初始化

Word文档免费下载Word文档免费下载:51单片机简易计算器代码 (共8页,当前第1页)

51单片机简易计算器代码相关文档

最新文档

返回顶部