Infrared (IR) Sensor ===================== The infrared sensor is used to detect obstacles by measuring distance using infrared radiation. The distance measured however is limited to 80cm. It has a transmitter and a receiver of radiation. The output signal differs in accordance to the obstacles. It remains high ‘1’ when there are no obstacles and low ‘0’otherwise. There is also a red led on its back that glows purple when it meets an obstacle. Connecting the IR Sensor ------------------------- The wires of the sensor are as follows: - Red – 5V - Green – GND - Yellow – Digital output In this example: 1. Red wire is connected to pin#2 2. Green wire is connected to pin#6 3. Yellow wire is connected to pin#7 The wiring of the Raspberry Pi to the breadboard, and the sensor is shown the figure below: .. image:: Circuits/infraredsensor.jpg :align: center Python Program to Show Obstacle Detection ------------------------------------------- .. literalinclude:: Code/infraredsensor.py :linenos: :language: python