#include "HX711.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Pines para el HX711
#define LOADCELL_DOUT_PIN  3
#define LOADCELL_SCK_PIN   2

HX711 scale;

LiquidCrystal_I2C lcd(0x27, 16, 2);


const int buttonPin = 7;
int buttonState = 0 ;


float maxWeight = 0.00;
float currentWeight = 0.00;

void setup() {

  Serial.begin(9600);
  lcd.backlight();


  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);


  lcd.init();
  lcd.backlight();

  pinMode(buttonPin, INPUT_PULLUP);
}

void loop() {
  currentWeight = scale.get_units(10)/420.0;

  if (currentWeight > maxWeight) {
    maxWeight = currentWeight;
  }
  buttonState = digitalRead(buttonPin);

  if (buttonState == LOW) {

    maxWeight = 0.00;

    delay(10);

  }


  lcd.setCursor(0, 00);
  lcd.print("Max: ");
  lcd.print(maxWeight, 2);
  lcd.print(" kg");

  delay(100);

}