I need that if object detection sensor (ir) is detected the servo should rotate 9 degree rotation.the problem is that i have a program shown below, it rotates 9 degree and it comes back to 0 degree I don't need to come to 0 degree ,it should continuously rotate . Please support me.
#include <Servo.h>
Servo tap_servo;
int sensor_pin = 7;
int tap_servo_pin =6;
int val;
if object detection sensor (ir) is detected the servo should rotate 9 degree rotation
do you mean "while" the sensor is detected?
the problem is that i have a program shown below, it rotates 9 degree and it comes back to 0 degree I don't need to come to 0 degree ,it should continuously rotate
instead of "continuously rotate", do you mean stay at 9 deg?
if you're using a switch as an sensor input, pressing the switch causes the servo to swing to 9 deg and releasing the switch causes the servo to swing back to 0 deg.
Remember that loop() repeats very very quickly. So every time round it checks the sensor and writes either 0 or 9 to the servo. In your code, as soon as the sensor goes low the servo returns to 0. What EXACTLY did you want it to do?
Also you need to be aware that writing(9) to a servo is asking it to move to POSITION 9. If you then write(9) to it again it will not rotate another 9 degrees, it will not move at all because it is already at position 9.
slipstick:
Remember that loop() repeats very very quickly. So every time round it checks the sensor and writes either 0 or 9 to the servo. In your code, as soon as the sensor goes low the servo returns to 0. What EXACTLY did you want it to do?
Also you need to be aware that writing(9) to a servo is asking it to move to POSITION 9. If you then write(9) to it again it will not rotate another 9 degrees, it will not move at all because it is already at position 9.
Steve
Thanks a lot your reply.
I need to rotate the servo by 9 degree if there is no object and delay by 30 sec and then need to check again , still there is no object it should rotate further 9 degree.
"I don't want to again come to 0 degree it should rotate 9 degrees continuously."
That is not very clear as to what you want to happen. Do you want the servo to keep moving back and forth looking for something to detect? A more detailed description is probably needed.
It sounds like you're saying you want to ADD 9 to the amount written to the servo each time there's no object. That's easy enough but I'm not sure that's really what you want. Try it and see, but bear in mind that 180 is the maximum you can write to a servo. After that you must stop adding 9 or go back to 0.
slipstick:
It sounds like you're saying you want to ADD 9 to the amount written to the servo each time there's no object. That's easy enough but I'm not sure that's really what you want. Try it and see
Steve
Yes, that is what I need but I should rotate up to 360 degrees.
is there any solution to that or we can use any other motor instead of servo
I am working on a robot. I want to rotate the plate by 9 degrees and increase each time by 9 degrees(9,18,27...) and rotate continuously
9 degree should rotate whenever object avoidance IR sensor detecting the object.
I have tried with servo, but I had the following problem
Every time it back to 0 positions which I don't want, I want only increment and rotate continuously
Servo rotating up to 180-degree to 270 degrees.
a) Continuous rotation servo - I could not get it right now
b) Modify a standard servo - Did it .but still not working
Question:
Please support to get to solve the above problem
Is there any other motor available to solve this problem.
It's fairly easy to get 9, 18, 27, 36 degrees etc but if you really need to go all the way to 360 degrees then you'll need something other than a standard servo.
A stepper motor could do what I think you want. So could a sail winch servo which has a maximum travel of around 3.5 turns. You could probably even use a geared DC motor and encoder. Lots of options.
It's a nice picture but it does not tell us much - not even its size or weight.
For a wheel to rotate it must be attached to something that can support it. What will that be? It would be a big help if you can post a diagram or sketch of the machine you hope to make.
I find it hard to make sense of this
9 degree should rotate whenever object avoidance IR sensor detecting the object.
because there is no indication of how the wheel could get in the way of, or move out of the way of an object.
Before choosing any motor you need to figure out the required torque and speed. There is a simple method for measuring torque in Stepper Motor Basics