Hi, I am doing a sketch that is something like this, I declare the main position of servo and a force sensitive resistor reading, then when the fsr detects a force move to one position, there are 4 possible movements, the problem is that I try the sketch and there are not the results I want, help me please, I ll be very thankful. Here is the code: and a written explication.
However I think you need to define when you want the servo to return and remember that loop() is a loop and repeats continuously so that unless the force is removed then the servos will continue to move as programmed.
Gerdelamora:
Hi, I am doing a sketch that is something like this, I declare the main position of servo and a force sensitive resistor reading, then when the fsr detects a force move to one position, there are 4 possible movements, the problem is that I try the sketch and there are not the results I want, help me please, I ll be very thankful. Here is the code: and a written explication.
I see that you have three servos as outputs and one analog input connected to a pressure sensitive resister. You're carrying out a sequence of servo movements triggered by the input being within certain ranges of values.
It looks broadly sensible, but I have no idea whether it will do what you intend because you haven't said what it is intended to do, or what it actually does.
Is your analog input being read correctly and detected as being within the range you intend? This would be obvious if you added some print statements to the relevent code blocks.
Are your servos all wired and configured correctly so that they move correctly when you command them to a new position?
Do you intend the servos to go through these sequences repeatedly while the input is within the corresponding range, or is this only intended to happen when the load enters the corresponding range?
You have some delays during the sequences but do not consistently delay after the sequence, so it's quite likely that the loop would restart the sequence and move the servos before they had completed moving to the last position in the sequence.
Okay I will apply four Serial.print each per argument.
When the fsr detects a force (four possible forces) depending on this move to the desired position ( four possible positions), just when the if becomes true, after arrive to desired position return to initial position, this is basically what I want, I will do this by adding an else after each if I think this need to work.
Thanks