#include <HX711_ADC.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
HX711_ADC LoadCell(4, 5);
LiquidCrystal_I2C lcd(0x27, 16, 2);
int taree = 6;
void setup() {
pinMode(taree, INPUT_PULLUP);
LoadCell.begin();
LoadCell.start(1000);
LoadCell.setCalFactor(420); // Callibration Factor
lcd.init();
lcd.backlight();
lcd.setCursor(1, 0);
lcd.print("Digital Scale ");
lcd.setCursor(0, 1);
lcd.print(" 5KG MAX LOAD ");
delay(3000);
lcd.clear();
}
void loop() {
lcd.setCursor(1, 0);
lcd.print("Digital Scale ");
LoadCell.update();
float i = abs(LoadCell.getData());
lcd.setCursor(0, 1);
lcd.print(i >= 5000 ? "-" : " ");
lcd.setCursor(8, 1);
lcd.print(i >= 5000 ? "-" : " ");
lcd.setCursor(1, 1);
lcd.print(i, 1);
lcd.print("kg ");
float z = i / 28.3495;
lcd.setCursor(9, 1);
lcd.print(z, 2);
lcd.print("oz ");
if (i >= 5000) {
i = 0;
lcd.setCursor(0, 0);
lcd.print(" Over Loaded ");
delay(200);
}
if (digitalRead(taree) == LOW) {
lcd.setCursor(0, 1);
lcd.print(" Taring... ");
LoadCell.start(1000);
lcd.setCursor(0, 1);
lcd.print(" ");
}
}