#include "HX711.h"
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
HX711 scale;
int led = 19;
int buzzer = 19;
//int DT_PIN = 12;
//int SCK_Pin = 13;
void setup() {
Serial.begin(9600);
lcd.init();
pinMode(led, OUTPUT);
pinMode(buzzer, OUTPUT);
Serial.println("Initializing the scale");
scale.begin(32, 18); // scale.begin(DT_PIN, SCk_PIN);
}
void loop() {
float berat = scale.get_units() * 0.00238;
Serial.print(berat);
Serial.println("kg");
if (berat > 4) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Overweight!!!");
digitalWrite(led, HIGH);
tone(buzzer, 1000); // Start the buzzer tone
delay(500);
noTone(buzzer); // Stop the buzzer tone
delay(500);
tone(buzzer, 1000); // Start the buzzer tone
delay(2000);
noTone(buzzer); // Stop the buzzer tone
digitalWrite(led, LOW);
} else {
digitalWrite(led, LOW);
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("Load Weight");
lcd.setCursor(4, 1);
lcd.print(berat);
lcd.setCursor(9, 1);
lcd.print("kg");
delay(1000);
}
}