The Sharp GP1A57HRJ00F is a sensor composed of an infrared emitter on one upright and a shielded infrared detector on the other.
By emitting a beam of infrared light from one upright to the other, the sensor can detect when an object passes between the uprights, breaking the beam. Used for many applications including optical limit switches, pellet dispensing, general object detection, etc. Gap width = 10mm
A breakout board is available.