If you have a mechanical stop then 2 methods become possible. Just rotate long enough so you know you are at the limit. Or use my library to detect the change in current to a winding when it hits the stop. Only a resistor is needed for hardware using this code.