Advertisement
Guest User

Untitled

a guest
Mar 1st, 2017
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. #include "HX711.h"
  2. // HX711.DOUT - pin #A1
  3. // HX711.PD_SCK - pin #A0
  4. HX711 scale(A1, A0);
  5. float read_ADC;
  6. float read_load;
  7. float read_average;
  8. void setup() {
  9. Serial.begin(38400);
  10. scale.set_scale(400.f); // this value is obtained by calibrating the scale with known weights; see the README for details
  11. scale.tare(); // reset the scale to 0
  12. Serial.print("read: \t\t");
  13. Serial.println(scale.read()); // print a raw reading from the ADC
  14. Serial.print("read average: \t\t");
  15. Serial.println(scale.read_average(20)); // print the average of 20 readings from the ADC
  16. Serial.print("get units: \t\t");
  17. Serial.println(scale.get_units(5), 1); // print the average of 5 readings from the ADC minus tare weight, divided
  18. // by the SCALE parameter set with set_scale
  19. Serial.println("Readings:");
  20. }
  21.  
  22.  
  23.  
  24. void loop() {
  25. read_ADC = scale.read();
  26. Serial.print("read: \t");
  27. Serial.println(read_ADC); // print a raw reading from the ADC
  28. read_load = scale.get_units();
  29. Serial.print("One reading:\t");
  30. Serial.print(read_load, 1);
  31. Serial.println(" Gram");
  32. read_average = scale.get_units(10);
  33. Serial.print("Average:\t");
  34. Serial.print(read_average, 1); // print the average of 10 readings from the ADC minus tare weight, divided
  35. // by the SCALE parameter set with set_scale
  36. Serial.println(" Gram");
  37. delay(1000);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement