Simple optical switch?
I'm assuming from your question that you are currently using Power Functions parts to control your conveyor. In order to achieve the sort of electrical automation that you are talking about, you'll need something like LEGO Mindstorms. The current line is called EV3. You'll need at minimum the Intelligent Brick, a light sensor, a motor, and a few cables. You can also buy the complete EV3 kit.

If that seems too pricey for you, you could try searching for used NXT (previous version), or even RCX (first version) Mindstorms kits.

Once you have the Mindstorms parts that you need, you'll just need to program the brick to do what you want using software on your computer.