Using a weight sensor and a siren

I have started a project that involves a weight sensor and an alarm siren. I am not very good with writing code and therefore need a way to write the code. What I am trying to do is set the siren to turn on when a certain amount of weight is taken off the sensor then turn off when after a few seconds or the weight is put back on the sensor. I have been struggling with this for a while so any kind of help is appreciated.

1 Like

What have you got so far? We are here to help you write your code, but let's start with what you know about writing code for Arduino... We are not here to write code for you.

So far I have a way to read the weight sensor and to start the siren, but the problem starts when it comes to combining the two
I just need to know how to reset the siren after it has turned on as well as read the weight being given by the sensor.

1 Like

Post your code here. Use Code tags and format.

This is around what I have so far

#include "HX711.h"


#define LOADCELL_DOUT_PIN  4
#define LOADCELL_SCK_PIN  5
#define RELAY_PIN 7


HX711 scale;


#define calibration_factor -7050.0


void setup() {
  Serial.begin(9600);
  Serial.println("HX711 scale demo");


  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
  scale.set_scale(calibration_factor);
  scale.tare();
  pinMode(RELAY_PIN, OUTPUT);
}


void loop() { 
  Serial.print("Reading: ");
  Serial.print(scale.get_units(), 1);
  Serial.print(" g");
  Serial.println();
  int currentWeight = digitalRead(LOADCELL_DOUT_PIN);
int threshold = 300;  
if (currentWeight > threshold) {
digitalWrite(RELAY_PIN, HIGH);
} else {
digitalWrite(RELAY_PIN, LOW);
}
delay(1000);
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.