So if I use a proximity sensor instead of a limit switch would that make a difference? I will make a sketch and I will show it to you. But all I need to know is how the controller can understand the previous rotation of the motor(forward/backwards) and then move at the opposite side. That's all I need I think.
Thank you very much for your quick replies.