Here we are going to interface an IR sensor module with Arduino to read its values and display them on the serial monitor. This IR sensor module can detect black and white colors in its proximity.

Infrared sensors are used to transmit and detect infrared radiations. They are mainly used for wireless communication between two devices for example; a TV or an AC remote, to detect motion, in Night vision cameras, or in missile guidance system to track the object, etc. Although Infrared rays are not visible to human eyes you can see them through the smartphone camera, if it does not block IR rays(Note: Apple devices uses a camera which blocks these IR radiations).


Infrared Raditaion

Infrared radiation is emitted by every ‘hot’ body and, conversely, where absorbed by a body, this gives rise to a development of heat; these thermal properties are common to all electromagnetic radiation, but are more sensitive to infrared radiation, which is therefore also called thermal radiation. Infrared emission is linked to transitions between the vibrational energy levels of the molecules.

Figure: Electromagnetic Spectrum
Figure 1: Electromagnetic Spectrum

Infrared Electromagnetic radiation has a wavelength between approximately 1 mm and 0.7 μm (7000 Å), i.e. frequency approximately between 300 GHz and 430 THz; it extends from the upper end of the Hertzian wave spectrum (microwave) to the lower end (red) of the light wave spectrum

Infrared Transmitter and Receiver

The infrared sensor module has a transmitter and receiver pair. It can be adapted to ambient light and detection distance through a potentiometer that is included on the plate, this distance is between 2cm ~ 30cm, with a detection angle of 35 °. These infrared emit signals at a certain frequency when an obstacle is detected (reflection surface). The signal captured by these sensors is conditioned by a comparator circuit, this is reflected by a green indicator LED, where depending on the user configuration, you can establish high (1 logical) and low (0 logical) levels of voltage.

Infrared sensor Module
Figure 2: Infrared sensor Module

This sensor is used in robots designed to evade obstacles or black/white line follower. The signal captured by the sensors can be taken directly to a control circuit such as a microcontroller, Arduino, among others, to be treated depending on the need of the user and / or specific application.

working of Infrared sensor
Figure 3: Working of an Infrared sensor



Interfacing IR sensor module with Arduino
Interfacing IR sensor module with Arduino

Figure 4: Connecting IR sensor with Arduino


Interfacing IR sensor module with Arduino and display readings on the Serial Monitor

  Interface IR sensor module with Arduino and display the
  readings on Serial Monitor

  2     IR Sensor
  5V    VCC
const int sensor = 2;     //sensor input pin
void setup() {
  Serial.begin(9600);     //start serial communication
  pinMode(sensor, INPUT); //make the pin as input pin
void loop() {
  int value = digitalRead(sensor);  //read sensor value

  if (value == HIGH)      //if value is HIGH
    Serial.println("White Surface"); //print white surface
  if (value == LOW)       //if value is LOW
    Serial.println("Black/No Surface"); //print black surface







6. FAQ’s

What is a comparator IC?

The basic function of a comparator is to determine whether an input voltage is higher or lower than a reference voltage. A simple comparator compares an input signal with a reference one and outputs a voltage continues at a high or low level (positive or negative) depending on whether the input signal is greater or less than the reference one. In fact, a comparator can be considered as a 1bit analog-to-digital converter.

Still, having doubts?

Ask your questions regarding Interfacing IR sensor module with Arduino in the comments section below or Contact Us.

This Post Has One Comment

  1. Avinash

    How to make a line follower using the IR sensor?

Leave a Reply