kozubovskyy

Untitled

Mar 15th, 2024
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. /**
  2. * Complete project details at https://RandomNerdTutorials.com/arduino-load-cell-hx711/
  3. *
  4. * HX711 library for Arduino - example file
  5. * https://github.com/bogde/HX711
  6. *
  7. * MIT License
  8. * (c) 2018 Bogdan Necula
  9. *
  10. **/
  11.  
  12. #include <Arduino.h>
  13. #include "HX711.h"
  14.  
  15. // HX711 circuit wiring
  16. const int LOADCELL_DOUT_PIN = 4;
  17. const int LOADCELL_SCK_PIN = 5;
  18.  
  19. const int pin2 = 2;
  20. const int pin3 = 3;
  21.  
  22. const int pin6 = 6;
  23. const int pin7 = 7;
  24.  
  25. const int pin8 = 8;
  26. const int pin9 = 9;
  27.  
  28. HX711 scale;
  29. HX711 scale2;
  30. HX711 scale3;
  31. HX711 scale4;
  32.  
  33. void setup() {
  34. Serial.begin(57600);
  35.  
  36.  
  37. scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
  38. scale2.begin(pin2, pin3) ;
  39. scale3.begin(pin6, pin7) ;
  40. scale4.begin(pin8, pin9) ;
  41.  
  42.  
  43. scale.set_scale(18.89);
  44. scale2.set_scale(18.89);
  45. scale3.set_scale(18.89);
  46. scale4.set_scale(18.89);
  47.  
  48. scale.tare();
  49. scale2.tare();
  50. scale3.tare();
  51. scale4.tare();
  52.  
  53. }
  54.  
  55. void loop() {
  56.  
  57. //Serial.println(scale2.get_units(10), 5);
  58.  
  59. long lettura = ((scale.get_units(5) + scale2.get_units(5) + scale3.get_units(5) + scale4.get_units(5))/4) ;
  60. /// Serial.println(lettura);
  61.  
  62. String stringOne = String(lettura) ;
  63. stringOne = stringOne + "g" ;
  64. Serial.println(stringOne);
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment