主要代码
- //主函数程序
-
- #include "system.h"
- #include "SysTick.h"
- #include "led.h"
- #include "usart.h"
- #include "hx711.h"
- #include "beep.h"
- #include "key.h"
-
-
- int main()
- {
- u8 res=0;
- u8 key=0;
-
- SysTick_Init(168);
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //中断优先级分组,分2组
- USART1_Init(115200);//波特率设置为115200
- LED_Init();//LED初始化
- BEEP_Init();//蜂鸣器初始化
- KEY_Init();//按键初始化
-
- hx711_init();//HX711模块初始化
-
- get_plet();//获取毛皮重量
- BEEP=1;
- delay_ms(1000);
- get_plet();//延时1s,再一次获取毛皮重量
- BEEP=0;
-
- while(1)
- {
- LED1=!LED1;//LED1灯在正常运行中不断闪烁
-
- res=get_suttle();//获取净重
- if(res==0)
- {
- printf("实时检测重量:%d克\r\n",hx_str.suttle);
- if(hx_str.suttle>2000)
- BEEP=1;
- else
- BEEP=0;
- }
- }
- delay_ms(300);
-
- key=KEY_Scan(0);
- if(key==KEY2_PRESS)
- {
- printf("物品检测重量:%d克\r\n",hx_str.suttle);
- }
- }
-
-
|