|
電路原理圖如下:
單片機(jī)源程序如下:
- #include "key.h"
- #include "led.h"
- #include "lcd12864.h"
- #include "HX711.h"
- #include "main.h"
- #include <intrins.h>
- #include <string.h>
- #include "eeprom52.h"
- #define uchar unsigned char
- #define uint unsigned int
- uchar temp; //儲(chǔ)存鍵值
- uint GapValue,GapValue1; //修改除數(shù)
- /*-------------外部定義函數(shù)或變量-----------------*/
- extern unsigned char code image[];
- extern void lcddisplay();
- extern unsigned long HX711_Read(void);
- extern void weight_get();
- extern void maopi_get();
- extern void display_price();
- extern void display_weight();
- extern void display_money();
- bit bdata flag_key;
- void delay1()
- {;;} //延時(shí)函數(shù) 大概10us
- void delay(uint x)
- {
- uint a,b;
- for(a=x;a>0;a--)
- for(b=110;b>0;b--); //延時(shí)時(shí)間函數(shù) 大概x=1000為1s
- }
- //定時(shí)器0以及l(fā)cd12864初始化
- void init()
- {
- rw=0;
- psb=1;
- delay1(); //根據(jù)時(shí)序圖操作
- write_com(0x30); //基本指令操作
- write_com(0x0c); //開顯示關(guān)光標(biāo),0x0e就是開顯示開光標(biāo)
- write_com(0x06); //寫入一個(gè)字符,地址加1
- write_com(0x01); //清除LCD的顯示內(nèi)?
- delay(5);
- }
- void main()
- {
- init_eeprom(); //開始初始化保存的數(shù)據(jù)
- init(); //LCD初始化
- maopi_get(); //獲取開機(jī)時(shí)候的毛重,所以開機(jī)時(shí)托盤上應(yīng)該為零重量 這里是必須要注意的
- start_lcd(); //開機(jī)動(dòng)畫及其應(yīng)該初次顯示的東西
- while(1)
- {
- weight_get(); //循環(huán)地獲取重量
- temp=keyscan(); //按鍵掃描
- //有效鍵值0-15
- if (temp<16)
- {
- key_select(temp);//循環(huán)地不停檢查是否有按鍵按下,按下則立馬執(zhí)行相應(yīng)動(dòng)作
- while(temp<16)
- {
- if(temp==10||temp==11) //這里是修改GapValue值得
- {
- key_select(temp);//再次確認(rèn)temp
- weight_get(); //繼續(xù)稱重顯示
- flag_key=1; //修改按鍵標(biāo)志
- }
- // temp=keyscan();
- }
- }
- write_eeprom();//保存設(shè)定參數(shù)
- }
- }
-
復(fù)制代碼
所有資料51hei提供下載:
hx711.7z
(2.24 MB, 下載次數(shù): 86)
2018-12-10 17:19 上傳
點(diǎn)擊文件名下載附件
|
評(píng)分
-
查看全部評(píng)分
|