[go: up one dir, main page]

0% found this document useful (0 votes)
20 views2 pages

New Text Document

Uploaded by

ahanafy085
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

New Text Document

Uploaded by

ahanafy085
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

//UR FAV PIZZA

#include "HX711.h"

// Define HX711 pins


#define DT 6
#define SCK 7

// Define output pin for HX711 signal (buzzer)


#define OUTPUT_HX711_SIGNAL_PIN 13

// Define sensor and Motor pins


#define SENSOR_PIN 2
#define LED_PIN 8

int SHmotor1pin1 = 8 ;
int SHmotor1pin2 = 6 ;

//UR FAV PIZZA

HX711 scale;

const float CALIBRATION_FACTOR = 770.0; // calibration factor


const float THRESHOLD_WEIGHT = 200.0; // Weight threshold in grams

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

// Initialize HX711 output pin


pinMode(OUTPUT_HX711_SIGNAL_PIN, OUTPUT);
digitalWrite(OUTPUT_HX711_SIGNAL_PIN, LOW);

// Initialize sensor and Motor pins


pinMode(SENSOR_PIN, INPUT); // Set sensor pin as input
pinMode(LED_PIN, OUTPUT); // Set LED pin as output
digitalWrite(LED_PIN, LOW); // Ensure LED is off initially

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");

// Check weight threshold


if (weight > THRESHOLD_WEIGHT) {
digitalWrite(OUTPUT_HX711_SIGNAL_PIN, HIGH); // Activate HX711 output signal
} else {
digitalWrite(OUTPUT_HX711_SIGNAL_PIN, LOW); // Deactivate HX711 output
signal
}
} else {
Serial.println("HX711 not found. Check wiring.");
}

// **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);

You might also like