Setting "detents" with Potentiometer

My son wants to program in “detents” or short stops across a range of the arm’s motion. We have a potentiometer in place to gauge the position of the arm, and there are two motors (ports 3 and 4, one inverted, on rx2 channel 6) that move the arm. He would like to give the drivers flexibility to put the arm where they like, but also establish “sweet spots” or pre-measured locations in the arc that are appropriate for cube pickup and specific goal heights. The idea is to do this by creating a brief stop at each sweet spot (pot value).

It could either be a pause while the button remains depressed, after which movement would resume. Or it could be a stop, requiring the driver to let up and press the button again.

One concern is that the pot values fly by so fast, even though our arm moves slow it’s hard for it to catch a single integer value. We tried to say “IF angle=520” take over motor control (at 127) for 500 ms. However the programming never saw 520. Then we gave it “IF angle>=520…etc” but then it couldn’t really move on to the next sweet spot without jerking through more unintended stops.

We’re really confused now. Any ideas?

I would look at this program, it should do what you need.

https://vexforum.com/t/example-program-closed-loop-control/15150/1