標(biāo)題: Arduino HX711模塊庫(kù)文件下載 [打印本頁(yè)]

作者: sh782945358    時(shí)間: 2019-6-10 00:05
標(biāo)題: Arduino HX711模塊庫(kù)文件下載
有些亂,不過(guò)能看


Arduino源程序如下:
  1. #include "hx711.h"

  2. long HX711_Buffer = 0;
  3. long Weight_Maopi = 0,Weight_Shiwu = 0;

  4. #define GapValue 430

  5. //****************************************************
  6. //初始化HX711
  7. //****************************************************
  8. void Init_Hx711()
  9. {
  10.         pinMode(HX711_SCK, OUTPUT);       
  11.         pinMode(HX711_DT, INPUT);
  12. }


  13. //****************************************************
  14. //獲取毛皮重量
  15. //****************************************************
  16. void Get_Maopi()
  17. {
  18.         Weight_Maopi = HX711_Read();               
  19. }

  20. //****************************************************
  21. //稱重
  22. //****************************************************
  23. long Get_Weight()
  24. {
  25.         HX711_Buffer = HX711_Read();
  26.         Weight_Shiwu = HX711_Buffer;
  27.         Weight_Shiwu = Weight_Shiwu - Weight_Maopi;                                //獲取實(shí)物的AD采樣數(shù)值。
  28.         Weight_Shiwu = (long)((float)Weight_Shiwu/GapValue);        
  29.         return Weight_Shiwu;
  30. }

  31. //****************************************************
  32. //讀取HX711
  33. //****************************************************
  34. unsigned long HX711_Read(void)        //增益128
  35. {
  36.         unsigned long count;
  37.         unsigned char i;
  38.         bool Flag = 0;

  39.         digitalWrite(HX711_DT, HIGH);
  40.         delayMicroseconds(1);

  41.         digitalWrite(HX711_SCK, LOW);
  42.         delayMicroseconds(1);

  43.           count=0;
  44.           while(digitalRead(HX711_DT));
  45.           for(i=0;i<24;i++)
  46.         {
  47.                   digitalWrite(HX711_SCK, HIGH);
  48.                 delayMicroseconds(1);
  49.                   count=count<<1;
  50.                 digitalWrite(HX711_SCK, LOW);
  51.                 delayMicroseconds(1);
  52.                   if(digitalRead(HX711_DT))
  53.                         count++;
  54.         }
  55.         digitalWrite(HX711_SCK, HIGH);
  56.         count ^= 0x800000;
  57.         delayMicroseconds(1);
  58.         digitalWrite(HX711_SCK, LOW);
  59.         delayMicroseconds(1);
  60.        
  61.         return(count);
  62. }
復(fù)制代碼

所有資料51hei提供下載:
HX711_AD.zip (1.59 KB, 下載次數(shù): 103)




作者: 大貓8888    時(shí)間: 2019-6-28 11:34
感謝

作者: jt110112119    時(shí)間: 2021-3-20 11:00
thanks all
作者: at58999    時(shí)間: 2022-3-21 22:11
大貓8888 發(fā)表于 2019-6-28 11:34
感謝

這個(gè)能用嗎




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1