#include "HX711.h"
// Pet food bowl weight
float calibrate = 5000.0/2100.0;
const int LOADCELL_DOUT_PIN = 13;
const int LOADCELL_SCK_PIN = 12;
HX711 scale;
void setup()
{
Serial.begin(9600);
delay(500);
pinMode(19, OUTPUT);
pinMode(18, OUTPUT);
pinMode(23, OUTPUT);
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
scale.tare(); // Reset scale
}
void loop()
{
// Read food bowl weight value
float Rawdata = scale.get_units();
float weight = Rawdata * calibrate;
// Check if weight is less than 1kg
if (weight < 1000.0) {
digitalWrite(19, LOW); // Turn on LED on pin 19
} else {
digitalWrite(19, HIGH); // Turn off LED
}
// Print weight (for debugging)
Serial.print("Weight (grams): ");
Serial.println(weight);
delay(1000);
}