Good day,
as a beginner I need advice on a project.
I have a code with 10 scales with hx711 but the code freezes during the process. On the LCD whenever it has to display the value from the scale.
Thanks for the advice.
code:
#include <LiquidCrystal_I2C.h>     
LiquidCrystal_I2C lcd( 0x27, 20, 4 );
    
#include "HX711.h"
byte c_hacek[8] = {  //definice znaku c s háčkem = č
  B01010,           // jednička svítí
  B00100,           // nula nesvítí
  B01110,
  B10000,
  B10000,
  B10001,
  B01110,
  };
#define calibration_factor_1 23000 //This value is obtained using the SparkFun_HX711_Calibration sketch
#define calibration_factor_2 23500 
#define calibration_factor_3 23500 
#define calibration_factor_4 -22300 
#define calibration_factor_5 23500
#define calibration_factor_6 23500
#define calibration_factor_7 23500
#define calibration_factor_8 23500
#define calibration_factor_9 23500
#define calibration_factor_10 23500
#define DOUT1  28
#define CLK1  29
const int Tare1 = 25;
#define DOUT2  30
#define CLK2  31
const int Tare2 = 22;
#define DOUT3  34
#define CLK3  36
const int Tare3 = 23;
#define DOUT4  38
#define CLK4  40
const int Tare4 = 24;
#define DOUT5  5
#define CLK5  6
const int Tare5 = 26;
#define DOUT6  42
#define CLK6  44
const int Tare6 = 8;  
#define DOUT7  47
#define CLK7  49 
const int Tare7 = 9;   
#define DOUT8  51
#define CLK8  53
const int Tare8 = 12; 
#define DOUT9  2
#define CLK9  3
const int Tare9 = 4;
#define DOUT10  32
#define CLK10  33
const int Tare10 = 7;
HX711 scale1;
HX711 scale2;
HX711 scale3;
HX711 scale4;
HX711 scale5;
HX711 scale6;
HX711 scale7;
HX711 scale8;
HX711 scale9;
HX711 scale10;
void setup() {
  Serial.begin(9600);
lcd.init( );
  lcd.backlight( );
lcd.createChar(1, c_hacek);   //odeslání definice 2. znaku
  scale1.begin(DOUT1, CLK1);
  pinMode(Tare1, INPUT);
  digitalWrite(Tare1, LOW);
  scale1.set_scale(calibration_factor_1); //This value is obtained by using the SparkFun_HX711_Calibration sketch
  scale1.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
  
  scale2.begin(DOUT2, CLK2);
  pinMode(Tare2, INPUT);
  digitalWrite(Tare2, LOW);
  scale2.set_scale(calibration_factor_2); //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.begin(DOUT3, CLK3);
  pinMode(Tare3, INPUT);
  digitalWrite(Tare3, LOW);
  scale3.set_scale(calibration_factor_3); //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 0
  
  scale4.begin(DOUT4, CLK4);
  pinMode(Tare4, INPUT);
  digitalWrite(Tare4, LOW);
  scale4.set_scale(calibration_factor_4); //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 0
  scale5.begin(DOUT5, CLK5);
  pinMode(Tare5, INPUT);
  digitalWrite(Tare5, LOW);
  scale5.set_scale(calibration_factor_5); //This value is obtained by using the SparkFun_HX711_Calibration sketch
  scale5.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
  scale6.begin(DOUT6, CLK6);
  pinMode(Tare6, INPUT);
  digitalWrite(Tare6, LOW);
  scale6.set_scale(calibration_factor_6); //This value is obtained by using the SparkFun_HX711_Calibration sketch
  scale6.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
  scale7.begin(DOUT7, CLK7);
  pinMode(Tare7, INPUT);
  digitalWrite(Tare7, LOW);
  scale7.set_scale(calibration_factor_7); //This value is obtained by using the SparkFun_HX711_Calibration sketch
  scale7.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
  scale8.begin(DOUT8, CLK8);
  pinMode(Tare8, INPUT);
  digitalWrite(Tare8, LOW);
  scale8.set_scale(calibration_factor_8); //This value is obtained by using the SparkFun_HX711_Calibration sketch
  scale8.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
  scale9.begin(DOUT9, CLK9);
  pinMode(Tare9, INPUT);
  digitalWrite(Tare9, LOW);
  scale9.set_scale(calibration_factor_9); //This value is obtained by using the SparkFun_HX711_Calibration sketch
  scale9.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
  scale10.begin(DOUT10, CLK10);
  pinMode(Tare10, INPUT);
  digitalWrite(Tare10, LOW);
  scale10.set_scale(calibration_factor_10); //This value is obtained by using the SparkFun_HX711_Calibration sketch
  scale10.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
  
  Serial.println("Readings:");
}
void loop() {
  lcd.clear() ;
  lcd.setCursor(0,0);
  lcd.print("V");
  lcd.write(byte(1));    //zobrazí č (znak 1)
  lcd.print("elstvo 1:");
  lcd.setCursor(12,0);
  lcd.print(scale1.get_units(),1); //scale.get_units() returns a float
  lcd.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
  
  /*Serial.print("Hmotnost: ");
  Serial.print(scale2.get_units(),1); //scale.get_units() returns a float
  Serial.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
  Serial.println();
  */
  lcd.setCursor(0,1);
  lcd.print("V");
  lcd.write(byte(1));    //zobrazí č (znak 1)
  lcd.print("elstvo 2:");
  lcd.setCursor(12,1);
  lcd.print(scale2.get_units(),1); //scale.get_units() returns a float
  lcd.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
  
  /*Serial.print("Hmotnost: ");
  Serial.print(scale3.get_units(),1); //scale.get_units() returns a float
  Serial.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
  Serial.println();
  */
  lcd.setCursor(0,2);
  lcd.print("V");
  lcd.write(byte(1));    //zobrazí č (znak 1)
  lcd.print("elstvo 3:");
  lcd.setCursor(12,2);
  lcd.print(scale3.get_units(),1); //scale.get_units() returns a float
  lcd.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
  
  /*Serial.print("Hmotnost: ");
  Serial.print(scale4.get_units(),1); //scale.get_units() returns a float
  Serial.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
  Serial.println();
  */
  lcd.setCursor(0,3);
  lcd.print("V");
  lcd.write(byte(1));    //zobrazí č (znak 1)
  lcd.print("elstvo 4:");
  lcd.setCursor(12,3);
  lcd.print(scale4.get_units(),1); //scale.get_units() returns a float
  lcd.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  delay (2000);
  lcd.clear() ;
  lcd.setCursor(0,0);
  lcd.print("V");
  lcd.write(byte(1));    //zobrazí č (znak 1)
  lcd.print("elstvo 5:");
  delay (2000);
  lcd.setCursor(12,0);
  lcd.print(scale5.get_units(),1); //scale.get_units() returns a float
  lcd.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
  
  lcd.setCursor(0,1);
  lcd.print("V");
  lcd.write(byte(1));    //zobrazí č (znak 1)
  lcd.print("elstvo 6:");
  lcd.setCursor(12,1);
  lcd.print(scale6.get_units(),1); //scale.get_units() returns a float
  lcd.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
  
  lcd.setCursor(0,2);
  lcd.print("V");
  lcd.write(byte(1));    //zobrazí č (znak 1)
  lcd.print("elstvo 7:");
  lcd.setCursor(12,2);
  lcd.print(scale7.get_units(),1); //scale.get_units() returns a float
  lcd.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
  delay(2000);
  lcd.clear() ;
  lcd.setCursor(0,0);
  lcd.print("V");
  lcd.write(byte(1));    //zobrazí č (znak 1)
  lcd.print("elstvo 8:");
  lcd.setCursor(12,0);
  lcd.print(scale8.get_units(),1); //scale.get_units() returns a float
  lcd.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
 
  lcd.setCursor(0,1);
  lcd.print("V");
  lcd.write(byte(1));    //zobrazí č (znak 1)
  lcd.print("elstvo 9:");
  lcd.setCursor(12,1);
  lcd.print(scale9.get_units(),1); //scale.get_units() returns a float
  lcd.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
  lcd.setCursor(0,2);
  lcd.print("V");
  lcd.write(byte(1));    //zobrazí č (znak 1)
  lcd.print("elstvo 10:");
  lcd.setCursor(12,2);
  lcd.print(scale10.get_units(),1); //scale.get_units() returns a float
  lcd.print(" kg"); //You can change this to kg but you'll need to refactor the calibration_factor
  
  delay(2000);
}
