The infrared obstacle avoidance sensor module (short for avoidance module) returns a signal when it detects an object in range. The sensor can detect a distance from 2 up to 40 cm. The module operates at 3.5 to 5 volts, and the working current is 20mA. There are 4 pins on this module, namely: the GND, "+", OUT and EN pins. The GND pin should be connected to the GND pin of Arduino, The "+" (VCC) pin should be connected to 5V pin of Arduino, the OUT (signal) pin should be connected to any digital pin of Arduino, and the EN (Enable) pin should be connected to any digital pin of Arduino.
The application of this module is typically used mostly to a wheeled robot, where it avoid obstacles with the use of this sensor module. The sensor detects the distance of an object based on the adjustable distance settings. The module has an infrared transmitter and receiver on board. The transmitter LED emits a certain frequency of infrared, in which the receiver LED will detect the signal from emitter and will trigger the digital on/off "signal" pin when a specific threshold "distance" has been detected. The module has two potentiometers. The potentiometer with the S02 label is for adjustment of trasmitter IR frequency, and the potentiometer with the E01 label is for adjustment of the distance from the object at which the sensor detects it. The function of this module is almost similar with the line tracking module functionality.
In the given code below, when the obstacle sensor detects signal, the LED flashes.
Code example for Avoidance Sensor Module
Upload the code to Arduino. Once uploaded, you may test the module by putting closer to a certain object (like wall, desk, etc.). Observe if the LED will change the display.