Tutorial – IR (infrared) sensor
An IR Sensor has two main parts. IR Transmitter(white) and IR Reciever(black).
The IR transmitter has to transmit infrared waves that will be received by the IR receiver. IR receiver constantly sends digital data in the form of 0 or 1 to “out” pin of the sensor.
As you can see there is also a potentiometer that you can use to adjust the sensibility. This means that you are regulating the distance to which it sends 1. When it sends 1, the on-board led will turn on.
As you can see it’s simple. Just wire GND to GND, VCC to 5V and OUT to a digital pin.
This sensor is also used in follow line projects. That’s because if you use a white sourface and draw a black line, the white surface will reflect the infrared. The black line won’t reflect it, so in that way you can program your robot to follow a line.