#include "HX711_ADC.h"
#include <LiquidCrystal_I2C.h>
int PIN_SCK = 8;
int PIN_DT = 9;
HX711_ADC LoadCell(PIN_DT, PIN_SCK);
LiquidCrystal_I2C lcd(0x27, 16, 2);
float current_weight = 0.0;
void weigth_display(float current_weight) {
lcd.setCursor(2, 0);
lcd.print("weighing Scale");
lcd.setCursor(0, 1);
lcd.print(current_weight, 0);
lcd.print("g ");
}
void weight_sensor_fn() {
LoadCell.update();
current_weight = LoadCell.getData();
Serial.println(String("weight :") + String(current_weight, 2) + String("g."));
weigth_display(current_weight);
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
lcd.clear();
LoadCell.begin();
LoadCell.start(1000);
LoadCell.setCalFactor(0.42);
Serial.println("Taring Sensor ...");
lcd.clear();
delay(150);
lcd.setCursor(3, 0);
lcd.print("Taring");
delay(200);
LoadCell.start(1000);
delay(400);
Serial.println("Ready!!!");
weigth_display(0.0);
Serial.println("Setup done.");
}
void loop() {
// put your main code here, to run repeatedly:
// weight_sensor_fn();
// weigth_display(0.0);
}