#include <HX711_ADC.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
HX711_ADC LoadCell(4, 5); // pin DT, pin SCK
LiquidCrystal_I2C lcd(0x27, 16, 2);
int Reset = 6;
int a = 0;
float b = 0;
void setup() {
pinMode (Reset, INPUT_PULLUP);
LoadCell.begin(); // mulai koneksi ke HX711
LoadCell.start(1000); // load cell mendapat waktu 1000ms untuk menstabilkan
/////////////////////////////////////
LoadCell.setCalFactor(425); // Kalibrasi LOAD CELL dengan berat tertentu, dan ubah nilai sesuai dengan pembacaan
/////////////////////////////////////
lcd.begin(16,2); // mulai koneksi ke modul LCD
lcd.backlight(); // menyalakan backlight
lcd.setCursor(1, 0); // set kursor ke baris pertama
lcd.print(" Project "); // mencetak ke LCD
lcd.setCursor(0, 1); // set kursor ke baris kedua
lcd.print(" Kelompok 3 "); // mencetak ke LCD
delay(3000);
lcd.clear();
}
void loop() {
lcd.setCursor(1, 0); // set kursor ke baris pertama
lcd.print("Digital Scale "); // mencetak ke LCD
LoadCell.update(); // mengambil data dari load cell
float i = LoadCell.getData(); // mendapatkan nilai keluaran
if (i<0)
{
i = i * (-1);
lcd.setCursor(0, 1);
lcd.print("-");
lcd.setCursor(8, 1);
lcd.print("-");
}
else
{
lcd.setCursor(0, 1);
lcd.print(" ");
}
lcd.setCursor(1, 1); // set kursor ke baris kedua
lcd.print(i, 1); // mencetak nilai yang diambil ke baris kedua
lcd.print(" Kg ");
float z = i;
if (i>=5000)
{
i=0;
lcd.setCursor(0, 0); // set kursor ke baris pertama
lcd.print(" Over Loaded ");
delay(200);
}
if (digitalRead (Reset) == LOW)
{
lcd.setCursor(0, 1); // set kursor ke baris kedua
lcd.print(" Mereset ... ");
LoadCell.start(1000);
lcd.setCursor(0, 1);
lcd.print(" ");
}
}