Menu Close

Arduino – Digital Infrared Sensor

This tutorial of Robo India explain the working concept of Infrared(IR) sensor as Digital sensor

1. Introduction:

This is a multipurpose infrared sensor which can be used for color detection.The sensor provides digital output. An on board LED is used to indicate the presence of an object. This module 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 potentiometer should be used to calibrate the sensor.

IR Sensor (by Robo India) especially designed for Line Follower Robot. Before detecting any object, mount that PCB on the desired location, then set the distance for black or white surface using on board potentiometer.

2. Hardware required

S.No.ItemQuantity
1.Arduino 1
2.Infrared Sensor module 1
3.Male to Female Jumper Wires 3

3. Building Circuit

4. Programming:

You may download this arduino sketch (code) from here.

const int ProxSensor=2;
int inputVal = 0;

void setup() 
{                
  pinMode(13, OUTPUT);          // Pin 13 has an LED connected on most Arduino boards:  
  pinMode(ProxSensor,INPUT);    //Pin 2 is connected to the output of proximity sensor
  Serial.begin(9600);
}

void loop() 
{
  if(digitalRead(ProxSensor)==HIGH)      //Check the sensor output
  {
    digitalWrite(13, HIGH);   // set the LED on
  }
  else
  {
    digitalWrite(13, LOW);    // set the LED off
  }
inputVal = digitalRead(ProxSensor);
Serial.println(inputVal);
delay(1000);              // wait for a second
}


5. Output

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.

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

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

Leave a Reply