Arduino candy dispenser

If you have an emitter to go with your sensor (receiver) then a broken lightbeam may work.