I designed this for someone who wanted to control the door to a chicken coop: Now in his case, he had two timers, one to open the door (left) and the other to close it (move right) so I did this with two inputs. But you can use a toggle flip-flop to turn the inputs on alternately. Switches LEFT and RIGHT are the limit switches at end of travel. They are normally closed and open when the door touches them. It could be done easily with a microcontroller, but the gentleman I did this for could only wire up switches and relays, so that's what I did. I never built one, but he did and was happy with it. Hope that helped.