#include <HX711.h>
#include <Tone.h>
const int LOADCELL_DOUT_PIN = 2;
const int LOADCELL_SCK_PIN = 3;
const int BUZZER_PIN = 4;
HX711 scale;
Tone toneGenerator;
void setup() {
Serial.begin(9600);
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
pinMode(BUZZER_PIN, OUTPUT);
}
void loop() {
float weight = scale.get_units(); // Read the weight from the load cell
Serial.println(weight);
if (weight > 25.0) {
toneGenerator.begin(BUZZER_PIN); // Start generating the tone
delay(1000); // Sound the alarm for 1 second
toneGenerator end(); // Stop the tone
}
delay(500); // Wait for 0.5 seconds before taking another reading
}