http://www.mpja.com/Opto-Interrupter/productinfo/18028%20OP
Are you going to use opto-interrupters like these? You could use the outputs to steer the input of a schmitt trigger circuit, biased half way between the on and off thresholds. Same thing with a comparator with hysteresis. Two analog options. You can drive an R-S flip flop or D or J-K flip flop with preset and clear pins as digital options. Then there are the relay options. So many simple ways to do it, depending on the voltages that you wish to work with and your actual application.
This would be better posted down in the technical area.
Joe