Please I need urgent help with this. I'm trying to program a servo motor to move in a particular direction after the load cell has sensed the weight of an object. That is, the direction in which the servo motor moves depends on the output value of the load cell. So far, the servo and load cell seem to work perfectly independently. The load cell output values are appropriate and correspond with the calibration factor i set. The problem is that the servo motor doesn't move according to the output value from the load cell, it just moves on its own, regardless of the output value of load cell.
I use if...else control loops for my program and i'd post it for you to see. Any help will be appreciated, thanks.
digitalRead() returns HIGH or LOW. Then you check to see if z is between 1.000 and 22.000 or between 22.000 and 30.000. How likely do you think that is?
Thanks Steve for replying. I'm a newbie to this, I posted the code because i believe there is something wrong with it. Please can you help me with the correction.
Unless you are trying to do something specific that you understand but I don't...just remove that line. You already set z in a more sensible looking way a few lines above.
BTW the code would be much easier to understand if it had a few comments and if you used meaningful names for variables not single letters like z. Who knows what a z is supposed to contain?
I accept that that line is incorrect and i've taken it off. Thanks Steve. And sorry for the absence of comments in the code.
From 'z =(scale.get_units(), 3)' the purpose of z in the code is to collect the value that (scale.get_units(), 3) generates so I can use it in the control loop, because when I put (scale.get_units(), 3) in the control loop it doesn't work.
But even z does not assume the value that (scale.get_units(), 3) generates.
Apart from the fact that my control loop may have some problems, I think the main issue is that z cannot attain the value generated by (scale.get_units(), 3). Because if z doesn't hold the correct value, the control loop will not work correctly.
Maybe I'm not doing it the right way, I'm trying to make z assume the value of (scale.get_units(), 3) but I may be doing it the wrong way. Any ideas or alternatives please?
Yes. This is true. When I set the code to display z, it shows 3. This is a problem for me.
Do you know a way with which I can take the value that (scale.get_units(), 3) generates and assign it to another variable? so I can use it for my control loops. Because the only thing I have been able to do with the value generated by (scale.get_units(), 3) is display it on the serial monitor.
Get rid of the ",3" and the extra parens. I don't know what the scale function does, so please read up on it and report back, along with a statement about what you are trying to do.