DC motor with 3(or more) programmed limits

Perhaps the wisest thing at this moment is to forget all about my example Several Things at a Time. When I linked to it I had not intended it to be the major distraction that it has become.

Go back to what I said in the final paragraph in Reply #25

However, to start with I would not bother with the 2nd and 3rd pieces in your loop() code. Just get the motor working in one direction and try to stop it after a specific encoder count. It will be easier if the motor is running slowly.

and move on from that as though Replies #26 to #30 had never happened.

...R

PS ... an important feature of programming is seeing ideas in one piece of code that can be transferred to a very different situation without necessarily copying the code. I just wanted you to see that the use of delay() in the code in your Reply #22 could be replaced by millis(). I did not intend you to take any notice of the servos or the Leds in my example code. And I certainly did not intend that the code in my example has any relevance to your problem.