Hello. I need your help. I have an arduino uno board,4 x hx711 and 4 load cells... And I want to weigh with 4 scales each separately, and each scales to activate a servo. That is, the first scale when the weight is less than 53g (0-53g) the first servo make 180 degrees else 0 degrees. The second scale when weighing is from 53g to 63g make the second servo 180 degrees otherwise 0. The third when the weigh is 63g to 73g make a sevo 180 degrees and the fourth when the weigh is Greater than 73g servo make a 180 degrees.
I can do it? You can tell me the code??
This is my code. I do not know how to put second load cell...
#include "HX711.h"
#define calibration_factor -5990.0 //This value is obtained using the SparkFun_HX711_Calibration sketch
#define DOUT A3
#define CLK A2
HX711 scale(DOUT, CLK);
#include "Servo.h"
Servo Servosmall;
int pos = 0;
int pos2=180;
int small=53;
void setup() {
Serial.begin(9600);
Serial.println("HX711 scale demo");
scale.set_scale(-5990); //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:");
Servosmall.attach(9);
}
void loop() {
Serial.print("Reading: ");
Serial.print(scale.get_units(20), 1); //scale.get_units() returns a float
Serial.print(" g "); //You can change this to kg but you'll need to refactor the calibration_factor
Serial.println();
if (scale.get_units() > small){
Servosmall.write(pos);
}
else {
Servosmall.write(pos2);
}
}
finally with a little effort I did it. it works perfectly.
Νow I want help.
I want with two buttons to change the price of small
a button for up (+1gr) and a button for down(-1gr)
how to do this;
This is my code
#include "HX711.h"
#define calibration_factor = -5990.0
HX711 scale(3,2);
HX711 scale2(5,4);
HX711 scale3(6,7);
HX711 scale4(9,8);
#include "Servo.h"
Servo Servosmall;
Servo Servomedium;
Servo Servolarge;
Servo Servoxlarge;
int pos = 0;
int pos2=180;
float small= 53;
float medium=63;
float large=73;
float xlarge=83;
void setup() {
Serial.begin(9600);
Serial.println("HX711 scale demo");
scale.set_scale(-5990); //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
scale2.set_scale(-5990); //This value is obtained by using the SparkFun_HX711_Calibration sketch
scale2.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
scale3.set_scale(-5990); //This value is obtained by using the SparkFun_HX711_Calibration sketch
scale3.tare(); //Assuming there is no weight on the scale at start up, reset the scale to
scale4.set_scale(-5990); //This value is obtained by using the SparkFun_HX711_Calibration sketch
scale4.tare(); //Assuming there is no weight on the scale at start up, reset the scale to
Serial.println("Readings:");
Servosmall.attach(13);
Servomedium.attach(12);
Servolarge.attach(11);
Servoxlarge.attach(10);
}
void loop() {
Serial.print("scale 1: ");
Serial.print(scale.get_units(1), 2); //παρε μοναδες (1) με (2) δικαδικα ψιφια
Serial.print(" g \t|"); //You can change this to kg but you'll need to refactor the calibration_factor
Serial.print("scale 2: ");
Serial.print(scale2.get_units(1), 2); //scale.get_units() returns a float
Serial.print(" g\t| "); //You can change this to kg but you'll need to refactor the calibration_factor
Serial.print("scale 3: ");
Serial.print(scale3.get_units(1), 2); //scale.get_units() returns a float
Serial.print(" g \t|"); //You can change this to kg but you'll need to refactor the calibration_factor
Serial.print("scale 4: ");
Serial.print(scale4.get_units(1), 2); //scale.get_units() returns a float
Serial.print(" g "); //You can change this to kg but you'll need to refactor the calibration_factor
Serial.println();
if (scale.get_units() > small){
Servosmall.write(pos);}
else {
Servosmall.write(pos2);}
if (scale2.get_units() < small && scale2.get_units() > medium){
Servomedium.write(pos);
}
else {
Servomedium.write(pos2);
}
if (scale3.get_units() < medium && scale3.get_units() > large){
Servolarge.write(pos);
}
else {
Servolarge.write(pos2);
}
if (scale4.get_units() < large && scale4.get_units() > xlarge){
Servoxlarge.write(pos);
}
else {
Servoxlarge.write(pos2);
}
if(Serial.available())
{
char temp = Serial.read();
if(temp == '+' || temp == 'a')
small += 1;
else if(temp == '-' || temp == 'z')
small -= 1;
}
}