Arduino candy dispenser

In your original post you mentioned an "RC infrared sensor". They come in pairs. An emitter and a receiver. If you have the pair, they may work to do what you want. (with the added bonus that the light beam will be invisible)

A normal photodiode is sensitive to a broader range of wavelengths so you will probably have to spend more time fiddling to get it working the way you want.