This is a 3mm Infrared break-beam sensor. These sensors are great for projects which need a simple and reliable way to detect motion or someone/something passing through an area. We also sell a 5mm version.
The sensors work as an emitter-receiver setup - the emitter sends IR light out which is detected by the receiver. When something/someone passes in front of the IR light (breaking the beam), the receiver detects the change and can be used as a trigger for your project.
The emitter and receiver can be around 25cm apart - anything further and results can be unreliable.
It's best to power these at 5V to get the best performance and range, however 3.3V works as well. Trial and error testing suggested!
To read a digital signal from the receiver, use a pull-up resistor (10k suggested) between the white and red wires on the receiver.