// LCD1602 to Arduino Uno connection example
#include <LiquidCrystal.h>
LiquidCrystal lcd(9, 8, 4, 5, 6, 7);
#include "HX711.h"
// HX711 circuit wiring
const int LOADCELL_DOUT_PIN_1 = 2;
const int LOADCELL_SCK_PIN_1 = 3;
const int LOADCELL_DOUT_PIN_2 = 10;
const int LOADCELL_SCK_PIN_2 = 11;
HX711 scale1;
HX711 scale2;
void setup() {
Serial.begin(57600);
scale1.begin(LOADCELL_DOUT_PIN_1, LOADCELL_SCK_PIN_1);
scale2.begin(LOADCELL_DOUT_PIN_2, LOADCELL_SCK_PIN_2);
lcd.begin(16, 2);
// you can now interact with the LCD, e.g.:
lcd.print("Ne pas toucher");
delay(1000);
scale1.set_scale();
scale1.tare(); //Reset the scale to 0
scale2.set_scale();
scale2.tare(); //Reset the scale to 0
long zero_factor = scale1.read_average(); //Get a baseline reading
//This can be used to remove the need to tare the scale. Useful in permanent scale projects.
lcd.println(zero_factor);
delay(1000);
lcd.clear();
lcd.print("Pret!");
delay(1000);
lcd.clear();
lcd.print("Poids CG");
}
void loop() {
GetScale(scale1,1);
GetScale(scale2,2);
delay(1000);
}
void GetScale(HX711 scale, byte No ){
lcd.setCursor(0, 1);
{
long reading = (scale2.read()+scale1.read());
lcd.print(reading);
lcd.setCursor(9, 1);
lcd.print(((47*(scale1.read()))+(225*(scale2.read())))/(scale2.read()+scale1.read()));
}
}