Here hope this helps:
Probably not the best code but give it a shot
#include <HX711_ADC.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
HX711_ADC LoadCell(4, 5);
LiquidCrystal_I2C lcd(0x27,20,4);
const int tarePin = 12; //Tare button at pin 12
float tareVal = 0;
float i=0;
void setup() {
LoadCell.begin();
LoadCell.start (2000);
LoadCell.setCalFactor(1.0);
lcd.init();
lcd.backlight();
pinMode(tarePin, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if(tarePin == HIGH){
//If push button is pressed
if(tareVal==0){
//Assign new tare
LoadCell.update();
tareVal = LoadCell.getData();
delay(100);
}else{
//When tare is assigned already and button is pressed clear tare
tareVal = 0;
}
}
LoadCell.update();
i = (LoadCell.getData() - tareVal);
lcd.setCursor(0, 0);
lcd.print("Weight[g]:");
lcd.setCursor(0, 1);
lcd.print(i);
}