标题: STM32驱动两个HX711称量物体并反馈的源码 [打印本页]

作者: 仙女你小哥    时间: 2018-3-16 21:03
标题: STM32驱动两个HX711称量物体并反馈的源码
单片机源程序如下:
  1. /************************************************************************************
  2.                                                
  3. *************************************************************************************/
  4. #include "stm32f10x.h"
  5. #include "delay.h"
  6. #include "HX711.h"
  7. #include "usart.h"



  8. int main(void)
  9. {               
  10.         Init_HX711pin();
  11.         delay_init();
  12.        
  13.         NVIC_Configuration();          //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
  14.         uart_init(9600);         //串口初始化为9600
  15.         //压力传感器1毛皮
  16.         Get_Maopi1();                                //称毛皮重量
  17.         delay_ms(1000);
  18.         delay_ms(1000);
  19.         Get_Maopi1();                                //重新获取毛皮重量
  20.         //压力传感器2毛皮
  21.         Get_Maopi2();                                //称毛皮重量
  22.         delay_ms(1000);
  23.         delay_ms(1000);
  24.         Get_Maopi2();                                //重新获取毛皮重量
  25.        
  26.        
  27.         while(1)
  28.         {
  29.                 Get_Weight1();        //得到WEIGHT_SHIWU1数据
  30.                 Get_Weight2();        //得到WEIGHT_SHIWU2数据

  31.                 printf("压力传感器1净重量 = %d g\r\n",Weight_Shiwu1); //打印   
  32.                 printf("压力传感器2净重量 = %d g\r\n",Weight_Shiwu2); //打印
  33.                 delay_ms(1000);


  34.         }
  35. }
复制代码

所有资料51hei提供下载:
STM驱动程序-HX711.rar (309.47 KB, 下载次数: 81)







欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1