Question: PLEASE HELP! I Used this code to get a reading from an S type load cell via and Arduino UNO borad. The current code give
PLEASE HELP! I Used this code to get a reading from an S type load cell via and Arduino UNO borad. The current code give me all the values between the specified range of 1lbs-2lbs. I'm trying to figure out how to obtain the first 10 readings and then take the average of that and have the serial monitor print one value that is the average of those 10 readings. #include "HX711.h" #define calibration_factor -7050.0 //This value is obtained using the SparkFun_HX711_Calibration sketch #define LOADCELL_DOUT_PIN 3 #define LOADCELL_SCK_PIN 2 HX711 scale; void setup() { Serial.begin(9600); Serial.println("HX711 scale demo"); scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN); scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch scale.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0 Serial.println("Readings:"); } void loop() { if(scale.get_units()>1.0 && scale.get_units()<2.0) { Serial.print("Reading: "); Serial.print(scale.get_units(), 1); //scale.get_units() returns a float Serial.print(" lbs"); //You can change this to kg but you'll need to refactor the calibration_factor Serial.println(); } } Thank you!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
