#include "HX711.h"
#define DT 3
#define SCK 2
#define OUTPUT_PIN 13
HX711 scale;
float calibration_factor = -7050; // adjust during calibration
float weight_limit = 1000; // grams
void setup()
{
Serial.begin(9600);
pinMode(OUTPUT_PIN, OUTPUT);
digitalWrite(OUTPUT_PIN, HIGH);
scale.begin(DT, SCK);
scale.set_scale(calibration_factor);
scale.tare();
Serial.println("HX711 Ready");
}
void loop()
{
float weight = scale.get_units(5);
Serial.print("Weight: ");
Serial.println(weight);
if(weight > weight_limit)
{
digitalWrite(OUTPUT_PIN, LOW); // OFF
}
else
{
digitalWrite(OUTPUT_PIN, HIGH); // ON
}
delay(500);
}