New Text Document
New Text Document
#include "HX711.h"
int SHmotor1pin1 = 8 ;
int SHmotor1pin2 = 6 ;
HX711 scale;
void setup() {
// Serial terminal
Serial.begin(9600);
// Initialize HX711
scale.begin(DT, SCK);
scale.set_scale(CALIBRATION_FACTOR); // Set your calibration factor here
scale.tare(); // Zero out the scale
Serial.println("System Initialized");
}
void loop() {
// **HX711 Functionality**
if (scale.is_ready()) {
// Get weight in grams
float weight = scale.get_units(10); // Average over 10 readings
Serial.print("Weight: ");
Serial.print(weight);
Serial.println(" g");
// **Sensor Functionality**
int sensorState = digitalRead(SENSOR_PIN); // Read the sensor state
if (sensorState == LOW) { // Adjust logic if the sensor output is active low
digitalWrite(LED_PIN, HIGH); // Turn on LED
} else {
digitalWrite(LED_PIN, LOW); // Turn off LED
digitalWrite(SHmotor1pin2, LOW);