top of page

Finding an obstacle using IR Sensor with Arduino


What is an Infrared Sensor?


An infrared sensor is an electronic instrument which is used to sense certain characteristics of its surroundings by either emitting and/or detecting infrared radiation. Infrared sensors are also capable of measuring the heat being emitted by an object and detecting motion.


Material Required:


Material Quantity

Arduino Uno 1

Infrared Sensor 1

Jumper cables 5

LED Bulb 1


Pinout Diagram:



Circuit Diagram:



Working:


This is a multipurpose infrared sensor which can be used for color detection. The sensor provides a digital as output. An on board LED is used to indicate the presence of an object. This digital output can be directly connected to an Arduino, Raspberry Pi or any other microcontroller to read the sensor output.IR sensors are highly susceptible to ambient light and the IR sensor on this sensor is suitably covered to reduce effect of ambient light on the sensor. The on board potentiometer should be used to calibrate the sensor.

An infrared light emitting diode (IR LED) emits light of Infrared range 700 nanometers (nm) to 1 mm. This light is not visible by naked eyes but can be seen by a camera (that is why these are also used in night vision cameras).


A photo diode gives response in term of change in resistance when light falls on it. That change is measured in terms of voltage. An IR LED and a Photo diode are used in a combination for proximity and color detection. An IR LED (transmitter) emits IR light, that light gets reflected by the object, the reflected light is received by an IR receiver (Photo Diode). Amount of reflection and reception varies with the distance. This difference causes to change in input voltage through IR input. This variation in input voltage is used for proximity detection.










For color detection application: The amount of reflected light depends upon the color of surface from which it is reflected. The reflection is different for different colored surfaces. This makes it a color detector.


Tested Programming Code:

int LED = 13; // Use the onboard Uno LED

int obstaclePin = 2; // This is our input pin int hasObstacle = LOW; // LOW MEANS NO OBSTACLE void setup() { pinMode(LED, OUTPUT);

pinMode(obstaclePin, INPUT);

Serial.begin(9600); } void loop() { hasObstacle = digitalRead(obstaclePin); //Reads the output of the obstacle sensor from the 7th PIN of the Digital section of the arduino if (hasObstacle == LOW) //LOW means path is clear, so red light connected to 13th Port connected LED is off. { Serial.println("Path is Clear"); digitalWrite(LED, LOW);//Illuminates the 13th Port LED } else { Serial.println("Stop something is ahead!!");

digitalWrite(LED, HIGH);

}

delay(200);

}


Precautions:


1. Double Check the connections before powering on the circuit.

2. Don’t use loose jumper cables.

3. Check Whether proper board is selected from Arduino IDE.

4. Ensure proper placement of sensor for correct working.


Conclusion:


You can successfully check for an obstacle using an IR sensor. Many more other applications can be made using Infrared sensor as it has many possibilities to work with.


Output:


Place the object in front of IR proximity sensor and observe the change in LED connected to board and Arduino as well. When you remove object you will see it gets turned off. The sensor outputs a logic 1 (+5V) at the digital output when an object is placed in front of the sensor and a logic 0 (0V), when there is no object in front of the sensor. (On Serial Monitor Press Ctrl+Shift+M)


Situation 1: When there is no obstacle in front of the sensor.






GET IN TOUCH

We'd love to hear from you

bottom of page