Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "HX711.h"
- // HX711.DOUT - pin #A1
- // HX711.PD_SCK - pin #A0
- HX711 scale(A1, A0);
- float read_ADC;
- float read_load;
- float read_average;
- void setup() {
- Serial.begin(38400);
- scale.set_scale(400.f); // this value is obtained by calibrating the scale with known weights; see the README for details
- scale.tare(); // reset the scale to 0
- Serial.print("read: \t\t");
- Serial.println(scale.read()); // print a raw reading from the ADC
- Serial.print("read average: \t\t");
- Serial.println(scale.read_average(20)); // print the average of 20 readings from the ADC
- Serial.print("get units: \t\t");
- Serial.println(scale.get_units(5), 1); // print the average of 5 readings from the ADC minus tare weight, divided
- // by the SCALE parameter set with set_scale
- Serial.println("Readings:");
- }
- void loop() {
- read_ADC = scale.read();
- Serial.print("read: \t");
- Serial.println(read_ADC); // print a raw reading from the ADC
- read_load = scale.get_units();
- Serial.print("One reading:\t");
- Serial.print(read_load, 1);
- Serial.println(" Gram");
- read_average = scale.get_units(10);
- Serial.print("Average:\t");
- Serial.print(read_average, 1); // print the average of 10 readings from the ADC minus tare weight, divided
- // by the SCALE parameter set with set_scale
- Serial.println(" Gram");
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement