Re: Setting "detents" with Potentiometer

I hate that some forums won’t let you post replies to them :confused:

So first, the stopping problem is relatively easy to overcome.

I’m doing this all in pseudo code, because I use RobotC (and I’m at work, not home where the compiler is).

First, to stop at close to a value… use an if that will accept a range, which you can fine tune.

That would give you a stop at ~40 “values”


if (value >= 480 && value <= 520)

You could make it a little more easily tuned by doing some defines/variables at the top and doing something like…


wobblyness=20
if (value >= (500-wobblyness) && value <= (500-wobblyness))

Now you can tune the number “wobblyness” w/o having to do a lot of re-working in your code (if you have 4 detants, you’d be changing 1 value instead of say 8.

The second problem you have to overcome is the fact that once you get to those points, you don’t want to just stop forever. You only want to pause for a moment.

I’m not sure how to solve that, might take me a little thinking (but it should be pretty easy)