My homebrew IR photogate consists of two parts, the emitter and the detector. The emitter contains an infrared LED from Radioshack, and a red LED to indicate when it has power. It uses a lens form an old laser pointer to focus the beam which increases the range by about 10%. The detector uses an infrared phototransistor in series with a 1000 Ohm resistor, and a full wave bridge to make it non-polar. When the beam is unobstructed, it registers pressed in touch sensor mode, and when the beam is blocked it registers released.