Sweep motion with Adafruit motor shield and Dc motor with encoder

Thanks for your reply

Would that not cause a conflict as at position 50 for example it is both >25 and <75 as are all numbers in the range 26-74

I found this on the net but not sure how to implement it and would be a bit like using a sledge hammer to crack a nut.