Hey guys. I am in need of a code that would help me with a assignment.
I need a load cell to switch on a led when a mass is detect on it. The connection is the one as follows. If anyone could get back to me on a code or anything that would help that would be great.
What code have you tried for this assignment?
i tried ones that i have found on public access forums but none of it worked for this application
Start by sharing what you've tried and please explain how it didn't perform as expected.
#include "HX711.h"
HX711 scale (A1, A0);
int ledPin = 13;
void setup()
{
Serial.begin(9600);
scale.set_scale(2280.f); //// this value is obtained by calibrating the scale with known weights
scale.tare();
pinMode (ledPin, OUTPUT);
}
void loop()
{
Serial.print(scale.get_units(), 1);
Serial.println("measurement");
delay(200);
if (scale.read () > 30) {
digitalWrite (ledPin, HIGH);
}
else{
digitalWrite (ledPin, LOW);
}
delay (100);
}
this is what i have but i need it to power the led when it reads 10 and above and power off if its below 10. i have already tried to change the unit but it doesnt work
You need to add a Serial.print() to show what values you are getting from your scale.read(). Also change >30 to >10.
Steve
what do you mean. could you add it to my code, tbh i have no experience to adruino. this is my first project
Typically people here will give you advice so you can make the changes yourself.
This is an assignment, you should turn in your own work.
The code has several Serial.prints in already. Copying one to add a new one should be easy enough. It goes just before the "if (scale.read.....) line.
And if you can't work out where >30 appears in the code now and change it to >10 then I'd say you're not making any effort. That's not how it works round here "help" doesn't mean "do the assignment for me".
Steve
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.