Infrared (IR) break-beam sensors are an efficient way to detect motion. They consist of an emitter that sends out a beam of invisible IR light and a receiver on the opposite side that detects the light. When an object that is not transparent to IR passes between the emitter and receiver, the beam is broken, signaling motion.
Compared to PIR sensors, break-beam sensors are faster and provide more precise control over the detection area. They are also less expensive than sonar modules. However, they do require both the emitter and receiver to be positioned on opposite sides of the monitored area.
This specific 5mm IR version works up to 50cm (20"). It can be powered by either 3.3V or 5V, with 5V offering better range, which is recommended. The receiver has an open collector transistor output, so to read a digital signal, a pull-up resistor is needed. Most microcontrollers can activate an internal pull-up resistor; if not, a 10K resistor should be connected between the signal wire (white) and the power wire (red). The sensor can also sink up to 100mA to ground, making it suitable for controlling relays, LEDs, or other devices.
Additionally, these sensors now come with premium wire ends for easy breadboard use, though the ends can be cut off if not needed.
Technical Details: