Button to Control Servo

I have tried lots of sketches and non of them work for me. I am trying to have 3 buttons, b1, b2, and b3. Each button makes a servo motor rotate once, twice or three times. So if button one is pressed it will rotate once and if button 2 is pressed, two rotations etc.

Any help is greatly appreciated.
Thanks

Most hobby servos only rotate about 180 degrees. You can position them anywhere in the 0 to 180 degree range.

Did you buy a special multi-turn or 'winch' servo? For example this winch servo can do eight full turns: Hitec HS-785HB Winch Servo - 3201_0 at Phidgets

You really ought to post those sketches, a schematic of the setup, and a link to the datasheet of the servo. Nobody can advise you without info like that.

Oh, and when you say the sketches didn't work, what does that mean? Did they compile?- if not, with what errors? If they did, then what happened when you ran them?- what took place that shouldn't have, what didn't take place that should have....

Kenn13542:
I have tried lots of sketches and non of them work for me. I am trying to have 3 buttons, b1, b2, and b3. Each button makes a servo motor rotate once, twice or three times. So if button one is pressed it will rotate once and if button 2 is pressed, two rotations etc.

Any help is greatly appreciated.
Thanks

That sounds like you are using servos modified for continuous rotation, is that true?

If so you cannot tell how many rotations such a servo has made as you only have control of stop/direction of rotation/speed of rotation. There is no built in feedback signal back to the arduino to tell you how far the servo has rotated. You would have to mount feedback sensors such as encoders onto the servos to be able to do what you wish.

Lefty

I have modified a servo to rotate a 360 degrees. But it would be ok if it only did a 180 degree motion when a button is pressed. Eg. B1 pressed makes the servo sweep left then right back to start position. When I say " the sketches didn't work" I meant that they uploaded fine but the physical servo wasn't doing what I wanted.

Kenn13542:
I have modified a servo to rotate a 360 degrees. When I say " the sketches didn't work" I meant that they uploaded fine but the physical servo wasn't doing what I wanted.

Well then you have given away the servo's ability to know where it is, as retrolefty said: you can no longer control its position like a servo.

Kenn13542:
When I say " the sketches didn't work" I meant that ... the physical servo wasn't doing what I wanted.

.... and now you know why, I guess. It no longer has any positional control.

None the less, some code would be helpful as the servo still knows where it is.

the servo still knows where it is.

No it doesn't.....

What used to be the position value sent to a normal servo, is now a direction and speed value sent to a continuous "servo". You have removed its sense of position by converting it.

The only way I can think of to make it turn 1 or 2 or 3 rotations is to add some kind of encoder to the shaft and use that to count the rotations. There's a recent thread about that.

I thought the whole point of a servo was that it has constant feedback to the micro controller and if you move it, it automatically moves back to the correct place. My servo is a micro servo and when it move it, it realize that it has been moved.

But you don't have a servo anymore. By modifying it for 360 rotation you have zapped its servo-ness.

You started with a diesel vehicle, took the diesel engine out and put in a petrol engine, yet still refer to it as a diesel and expect it to run on diesel....

You might be better off with a stepper motor, although that doesn't have feedback either. But if you send a 1.8 degree/step stepper 200 pulses, it should do a 360....

Ok I'll look into them more, thankyou

Kenn13542:
I thought the whole point of a servo was that it has constant feedback to the micro controller and if you move it, it automatically moves back to the correct place. My servo is a micro servo and when it move it, it realize that it has been moved.

No, even when using a unmodified servo there is no feedback information going from the servo back to the arduino.

In classic process control terminology the arduino sends a desired 'setpoint' value to the servo, the servo then compares it's present position to the desired setpoint position and moves if there is a difference in those two values. At no time is the arduino aware of if the servo is actually moving or not, and if moving when it will reach the desired position.

From the arduino's perspective the servo is running in "open loop control' (send it a command position and it will figure out how and when to get to that position), while the servo itself is operating in a classic automatic feedback control mode (continuously compare setpoint position with internal feedback position and drive motor speed and direction until those two values are the same).

Lefty