资源简介
基于proteus的计算器,c语言编程,设计的一个在proteus上仿真的计算器

代码片段和文件信息
#include
#define uchar unsigned char
#define uint unsigned int
uchar code wei[] = {0x01 0x02 0x04 0x08};
uchar code table[] = {0xc0 0xf9 0xa4 0xb0 0x99
0x92 0x82 0xf8 0x80 0x90 0xff
0x83 0xc6 0xa1 0x86}; //+ - * /
uchar dbuf[4] = {10 10 10 10};
uchar operand1[3] operand2[3];
uint value1 value2 value;
uchar cut1 = 0 cut2 = 0 bool = 0;
void delay(uint z)
{
uint xy;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
uchar keyscan()
{
uchar temp temp1 temp2 key;
P1 = 0x0f;
if(P1 != 0x0f)
delay(100);
if(P1 != 0x0f)
{
temp1 = P1;
P1 = temp1 | 0xf0;
temp2 = P1 & 0xf0;
P1 = 0x0f;
} while( P1 != 0x0f);
temp = temp1 + temp2;
switch(temp)
{
case 0xbe : key = 1;
break;
case 0xbd : key = 2;
break;
case 0xbb : key = 3;
break;
case 0xde : key = 4;
break;
case 0xdd : key = 5;
break;
case 0xdb : key = 6;
break;
case 0xee : key = 7;
break;
case 0xed : key = 8;
break;
case 0xeb : key = 9;
break;
case 0x7d : key = 0;
break;
case 0x77 : key = ‘+‘;
break;
case 0xb7 : key = ‘-‘;
break;
case 0xd7 : key = ‘*‘;
break;
case 0xe7 : key = ‘/‘;
break;
case 0x7b : key = ‘=‘;
break;
case 0x7e : key = ‘$‘;
break;
default : key = ‘#‘;
break;
}
return key;
}
uint compute(uint va1uint va2uchar optor)
{
uint value;
switch(optor)
{
case ‘+‘ : value = va1+va2; break;
case ‘-‘ : value = va1-va2; break;
case ‘*‘ : value = va1*va2; break;
case ‘/‘ : value = va1/va2; break;
default : value = va1; break;
}
return value;
}
void buf(uint val)
{
uchar i;
if(val == 0)
{
dbuf[3] = 0;
i = 2;
}
else
for(i = 3; val > 0 && i >= 0; i--)
{
dbuf[i] = val % 10;
val /= 10;
}
for( ; i > 0; i--)
dbuf[i] = 10;
}
void disp(void)
{
uchar n;
for(n=0;n<4;n++)
{
P2=wei[n];
P0=table[dbuf[n]];
delay(10);
}
}
//void error()
//{
// uchar n;
// for(n=0;n<4;n++)
// {
// P2=wei[n];
// P0 = 0x00;
// delay(20);
// }
//}
void init()
{
uchar i;
buf(0);
disp();
value = 0;
cut1 = cut2 = 0;
bool = 0;
for(i = 0;i < 3;i++)
{
operand1[i] = 0;
operand2[i] = 0;
}
}
void main()
{
uchar ckey operator;
init();
while(1)
{
ckey = keyscan();
if(ckey == ‘$‘)
init();
if(ckey != ‘#‘)
{
if(ckey>=0&&ckey<=9)
{
switch(bool)
{
case 0:
if(cut1 < 3)
{
operand1[cut1] = ckey;
switch(cut1)
{
case 0: value1 = operand1[0];
break;
case 1: value1 = operand1[0]*10+operand1[1];
break;
case 2: value1 = operand1[0]*100+operand1[1]*10+operand1[2];
break;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-03-14 14:47 基于proteus的计算器\
文件 4648 2017-03-05 14:10 基于proteus的计算器\play.c
文件 3477 2017-03-05 14:10 基于proteus的计算器\计算器.hex
文件 18694 2017-03-05 18:11 基于proteus的计算器\计算器.pdsprj
- 上一篇:IP TCP UDP校验和计算
- 下一篇:山大C++实验
相关资源
- 电子时钟 有C语言程序,PROTEUS仿真图
- c++ 多功能计算器
- Proteus 8.6仿真STM32F103C6
- Proteus仿真:动态数码管
- Proteus仿真:基于定时器的可调时钟
- Proteus仿真:DS1302(时钟or日历).rar
- Proteus仿真:LCD液晶屏显示.rar
- Proteus仿真:LED流水+定时器.rar
- Proteus仿真:PID算法输出.rar
- C语言课设计算器
- 基于51单片机的简易计算器
- 多功能计算器实现C++代码以及代码详
- C++简单计算器的实现
- 单片机C语言与PROTUES仿真技能实训
- C++版计算器带括号dos版本
- C语言实现51单片机和ADC0809芯片的AD模
- VC++课程设计 计算器
- VC仿Xp计算器
- VS2008 MFC简易计算器
- MFC登录注册系统C++
- 数据结构课程设计,C++计算器MFC
- MFC计算器编程,可视化,含详细实现
- MFC实现简单计算器支持加减乘除和括
- VC++ 对话框 滚轮 计算器
- C++课程设计计算器MFC
- 基于单片机控制的LED点阵屏 含设计报
- 多功能计算器 vc++ mfc
- 楼宇对讲系统proteus仿真+源代码
- vc60写的四则混合运算计算器
- C++中,用mfc做的可视化的计算器程序
评论
共有 条评论