|
/* S16 S12 S8 S4分别是123+
S15 S11 S7 S3分别是456-
S14 S10 S6 S2分别是789*
S13 S9 S5 S1分别是0 CLR = /
*/
/* 实现两个数的运算,每个数的位数至少可以八位 */
#include<reg52.h>
typedef unsigned char uint8;
typedef unsigned int uint16;
sbit rw=P2^5;
sbit rs=P2^6;
sbit e=P2^7;
sbit led=P3^7;
sbit beep=P2^0;
uint8 key,num;
uint8 fuhao;//定义具体的那个符号,是加减还是乘除。
uint8 flag; //定义有没有按下符号键,这个是统称
long a,b,c,d; //定义运算数据的第一个和第二个及等于的数变量
uint8 k; //定义小数点后面显示的位数
uint8 biao;
uint8 dat1[]={1,2,3,0x2b-0x30, 4,5,6,0x2d-0x30, 7,8,9,0x2a-0x30, 0,0x01-0x30,0x3d-0x30,0x2b-0x30 };//保存显示的数据
void delay(uint16 i)
{
while(i--);
}
void lcdwrc(uint8 c)
{
delay(1000);
rs=0;
rw=0;
e=0;
P0=c;
e=1;
delay(1000);
e=0;
}
void lcdwrd(uint8 dat)
{
delay(1000);
rs=1;
rw=0;
e=0;
P0=dat;
e=1;
delay(1000);
e=0;
rs=0;
}
void lcdinit()
{
delay(1500);
lcdwrc(0x38);
delay(500);
lcdwrc(0x38);
delay(500);
lcdwrc(0x38);
delay(500);
lcdwrc(0x38);
lcdwrc(0x08);
lcdwrc(0x01);
lcdwrc(0x06);
lcdwrc(0x0c);
key=0;
num=0;
flag=0;
fuhao=0;
a=0;
b=0;
c=0;
d=0;
biao=0;
led=0;
}
void keyscan()
{
P1=0xfe; //令第一行为0,然后判断是哪一列按下
if(P1!=0xfe)
{
delay(1000);
if(P1!=0xfe)
{
key=P1&0xf0;
switch(key)
|
|