#include <HX711.h>
#include <LiquidCrystal.h>

//pin declaration
#define BUTTON_PIN 7

//scale object creation
HX711 scale;
LiquidCrystal lcd(12,11,5,4,3,2);

//By default, the button is not pressed
int BUTTON_STATE = 0;

void setup() {
  // put your setup code here, to run once:  
  pinMode(BUTTON_PIN, INPUT_PULLUP);

  //Set scale
  //scale initialization
  scale.begin(A1, A0); 
  //set scale
  scale.set_scale(420);//for the same gain with stimulation

  //LCD initialization
  //set columns and rows
  lcd.begin(16,2);
  //Title: LUX
  lcd.print("Weight(kg):");

}

void loop() {
  // put your main code here, to run repeatedly:
  // when the button is NOT pressed, due to PULLUP mode,
  // the level of BUTTON_PIN is HIGH, so the button's state should be !BUTTON_PIN

  BUTTON_STATE = !digitalRead(BUTTON_PIN);
  // When pressed
  if (BUTTON_STATE == HIGH){
    delay(500);
    scale.tare();
    lcd.setCursor(0,1);
    lcd.print("    Taring    ");
    delay(1000);
    lcd.clear();
    lcd.print("Weight(kg):");
  }

  //print luminance value on LCD
  lcd.setCursor(0,1);
  lcd.print(scale.get_units(5));

}