/**
* Complete project details at https://RandomNerdTutorials.com/arduino-load-cell-hx711/
*
* HX711 library for Arduino - example file
* https://github.com/bogde/HX711
*
* MIT License
* (c) 2018 Bogdan Necula
*
**/
#include <Arduino.h>
#include "HX711.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 2;
const int LOADCELL_SCK_PIN = 3;
const int LEDPIN = 4;
HX711 scale;
void setup() {
Serial.begin(57600);
Serial.println("Initializing the scale");
Serial.println("Remove Any Weight from the scale");
delay(1000);
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
scale.set_scale(0.42);
scale.tare();
Serial.println("Scale Ready");
Serial.println("Setting Up LCD");
lcd.begin(16,2);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Urin Level:");
Serial.println("Setting up Buzzer");
pinMode(LEDPIN, OUTPUT);
digitalWrite(LEDPIN, LOW);
Serial.println("Ready");
}
void loop() {
float reading;
lcd.setCursor(0,1);
reading = scale.get_units() / 1.010;
lcd.print(reading);
lcd.print(" Ml");
if (reading >= 4000.0)
{
LEDON();
} else{
LEDOFF();
}
delay((500));
}
void LEDON() {
digitalWrite(LEDPIN, HIGH);
delay((200)); // Turn on the buzzer
digitalWrite(LEDPIN, LOW);
}
void LEDOFF() {
digitalWrite(LEDPIN, LOW); // Turn off the buzzer
}