how to use a servo as a controller

i'm trying to read if a servo is going clockwise, counter clockwise or simply standing still.

Attach a pot to the shaft?
Examine the values you last wrote to it?

cookiedk920:
i'm trying to read if a servo is going clockwise, counter clockwise or simply standing still.

What is driving the servo ?

cookiedk920:
i'm trying to read if a servo is going clockwise, counter clockwise or simply standing still.

If you want to use a servo as a controller (an input device) you will need to measure the voltage on the wiper of the feedback pot. That will allow you to move the servo shaft manually and measure the position of the servo. The servo will fight you if it is getting control pulses telling it to stay at a particular position. Use .detach() to turn off the servo control pulses. You can later use .attach() to take control of the servo and play back the motions you recorded.

cookiedk920:
i'm trying to read if a servo is going clockwise, counter clockwise or simply standing still.

this can be done in software without a pot.

since you are giving it instructions to move, you should be able to create functions that will be able to tell you:

  • if it has reached its destination
  • what direction it is moving
  • its current position

But that requires you to control the movements with single increment precision. that is, rather than a single write() command, you would generate a function that sets the target position and then move the servo in increments to that destination. All of that could be done as quickly as the single write() command or more slowly for a smoother move to the new position.

I can show you an example of just how that may be done.

since you are giving it instructions to move,

I don't think that we have established that quite yet.

UKHeliBob:
I don't think that we have established that quite yet.

Well, "you" is the program(er)... so yes it is established. :wink:

A servo that doesn't move isn't a servo, it is a ballast on your project or a pricey paperweight (of which I have a few).

I'm not convinced it is established - the servo could be part of an RC system.

Well, "you" is the program(er)... so yes it is established.

We don't know yet who or what is controlling the servo.

currently I have it setup to an arduino uno. and i am looking for a way to take the input from the servo and use it as a steering wheel in processing

cookiedk920:
currently I have it setup to an arduino uno. and i am looking for a way to take the input from the servo and use it as a steering wheel in processing

Does the servo control the wheel, or the wheel control the servo? :slight_smile:

the servo is the wheel

What kind of servo do you have. Continuous rotation, multi turn, 270 degree?

As @johnwasser described you will need to get access to the internal potentiometer which indicates position. Some continous rotation servos do not have one.

There is plenty of examples to be found on the internet about modifying a hobby servo to get position information from the internal pot.