#include "HX711.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
const int pinDOUT = 2;
const int pinSCK = 4;
HX711 scale;
LiquidCrystal_I2C lcd(0x27, 16, 2); // Address 0x27 for a 16x2 LCD
void setup() {
Serial.begin(115200);
scale.begin(pinDOUT, pinSCK);
scale.set_scale(0.42);
scale.tare();
lcd.init(); // Initialize the LCD
lcd.backlight(); // Turn on the backlight
}
void loop() {
if (scale.is_ready()) {
long reading = scale.get_units(3);
float kg = float(reading) / 1000;
Serial.print("Weight: ");
Serial.print(kg, 2);
Serial.println(" kg");
lcd.setCursor(0, 0); // Set cursor to the first column (0) and first row (0)
lcd.print("Weight:");
lcd.setCursor(0, 1); // Set cursor to the first column (0) and second row (1)
lcd.print(kg, 2);
lcd.print(" kg");
}
delay(100); // Add a small delay to stabilize readings
}