Menu Close

Arduino – IR Proximity and color detection sensor

This tutorial of Robo India explain the working concept of Infrared(IR) sensor for color detection and proximity. The constructed circuit is performed on Arduino platform.

1. Introduction:

A step by step illustrated tutorial to use IR Sensor on Arduino. This tutorial explains the concept and construction of IR Sensor for color detection and proximity measurement. This sensor comprises following two main parts (IR-LED and Photo Diode).

1.1 IR LED (Infrared Transmitter): It is as same as other LED we generally see, but it emits light of Infrared range 700 nanometers (nm) to 1 mm. This light is not visible through naked eyes but can be seen by camera (that is why these are also used in night vision camera). Following image shows how IR is seen on camera. In this image IR LED is ON.

In the following image IR LED is OFF(This is how it is seen by naked eyes). So camera is a good option to test whether IR LED is working or not.

1.2 Photo Diode: It gives response in term of change in resistance when light falls on it. That change we measure in terms of voltage.

1.3 IR Sensor as a proximity sensor:

IR LED (Transmitter) emits IR light, that light get reflected at the object, the reflected light is received by IR receiver (Photo Diode). Amount of reflection and reception as the distance varies. This difference causes to change in input voltage through IR input. We observe these values and use it out projects. This is our Proximity sensor. Following diagram explains this concept.

Application of this sensor can be an obstacle avoiding robot.

1.4 IR sensor as color detector.
Lets see above mentioned concept from a different angle. The amount of reflection light will also depend upon the color of surface from which it is being reflected. Black is said to be perfect absorber and white is to be said perfect reflector. The reflection will be different for different colors. Thus make it a color detector.

Application of this sensor can be a line follower, a micro mouse or a grid solver.

Following diagram will help you to understand the concept of IR sensor as a color detector.

2. Required Hardware

Following Hardware will be required to perform this sketch of shift register.

S.No.ItemQuantity
1.R-Board with FTDI or Arduino Board1
2.Bread Board1
3.Male to male Jumpers 5
4.100 OHM Resistance 10K OHM Resistance11
5.IR LED Photo Diode Pair1

3. Building Circuit

Make following circuit with the help of above mentioned components.

3.1 You may go with Robo India’s R-Board(UNO Compatible)-

Here is the schematic of this circuit-

or

3.2 You may go with original Arduino UNO Board-

Here is the schematic of this circuit-

4. Programming:

Once we are done with circuit part, here is our programme to this circuit. Every command of the following programme is explained in the comment section.

Programming is simple Analog input programming. Input is coming from Photo Diode to Pin A0. Upload the programme to Arduino board and observe change in value at serial port. These values are useful while making an application using this IR sensor.

You may download this code (Arduino Sketch) from here.

/*
Tutorial of Analog IR Sensor.
Prepared by Robo India.
www.roboindia.com
 */

int analog_ip = A0;   // select the input pin Photo Diode.
int inputVal = 0;     // to store photo diode input


void setup() {
  Serial.begin(9600);   // Setup Serial Communication.               
  Serial.print("ROBO INDIA\nroboindia.com\nTutorial on Analog IR Sensor.\n");  
}

void loop(){
    inputVal = analogRead(analog_ip); // Reading and storing analog input value.

        Serial.print("Input Value:");
        Serial.print(inputVal);       // Printing Analog input value of Photo Diode.
        Serial.print("\n");           // moving to new line
        delay(500);                   // Waiting for a while.

  
  
}

5. output:

Here is the output of this tutorial-

6. Following Product of Robo India can be useful for this circuit:

This sensor of Robo India gives both Analog and digital output.

If you have any query please write us at info@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
http://roboindia.com



Leave a Reply