I finished putting together an optical commutation circuit on a breadboard tonight. It uses an IR emitter/detector pair to trigger timer chips that ultimately turn on power transistors to drive solenoids. The solenoids are logically opposite, so they alternate as the IR beam is made and broken.
The timer chips aren’t strictly necessary, but they prevent the solenoids from staying on too long and burning up. You can see this in the video below when I am blocking and unblocking the IR path using a playing card–I sometimes leave the card in or out for a few moments, during which time whichever solenoid is powered returns to a resting state after about one second.
I’ll use this circuit to drive the two solenoids in my solenoid engine, which will have a rotating half-moon to block and unblock the IR beam.