1)控制显示;
2)键盘输入价格;
3)价格计算;
4)报警上下限设置;
5)声光报警;
6)清零.去皮.累计
键盘使用:
价格是在0-9取整数,设置按键进入报警上下限设置
每按增加按钮一次加0.01kg,同理,每按一次减少按钮
减去0.01按清零按钮退出设置,结果按钮是在输入价格
之后计算总价,然后设置按钮重新称重。
总体键盘实现的功能:矩阵键盘,然后对应的1-9数字,设置、加减、累计、清零、去皮、计算功能。
#include
#include
#include
#include
#define uchar unsigned char
#define uint unsigned int
#define BUSY 0x80 //常量定义
#define DATAPORT P0
sbit ADCS =P3^5;
sbit ADDI =P3^7;
sbit ADDO =P3^7;
sbit ADCLK =P3^6;
sbit LCM_RS=P2^0;
sbit LCM_RW=P2^1;
sbit LCM_EN=P2^2;
sbit beep =P3^0;
sbit led = P3^1;
uint x1,y1,z1=0,w1,temp1;
uchar ad_data,k,n,m,e,num,s; //采样值存储
uchar total[10];
uchar totalNum = 0;
bit flag = 0;
bit flag_peel = 0;
bit flag_total = 0;
char press_data; //标度变换存储单元
unsigned char ad_alarm; //报警值存储单元
unsigned char press_ge=0; //显示值百位
unsigned char press_shifen=0; //显示值十位
unsigned char press_baifen=0; //显示值个位
unsigned char press_qianfen=0; //显示值十分位
unsigned int alarm_value = 4200;
unsigned int price_total = 0;
float press;
uchar code str0[]={"Weight: . Kg "};
uchar code str2[]={"Price: "};
uchar code str3[]={"Total: "};
uchar code str4[]={" Change Alarm "};
uchar code str5[]={" . Kg "};
uchar code str6[]={"Peel: 1.11 Kg "};
uchar code str7[]={"Total: "};
uchar code table2[]={0x37,0x38,0x39,0xfd,0x34,0x35,0x36,0x78,0x31,0x32,0x33,0x2d,0x3d,0x30,0x2e,0x2b}; //键盘码
void delay(uint);
...省略部分程序