Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Sensors & Modules

Infrared Obstacle Sensor: Line Follower and Object Detection

Infrared Obstacle Sensor: Line Follower and Object Detection

April 1, 2026 /Posted by / 0

Infrared obstacle sensors are the building blocks of line-following robots, edge detection systems, and proximity triggers. These tiny modules emit IR light and detect the reflection, outputting a digital HIGH or LOW signal based on whether an object (or a line on the ground) is present within their detection range. At ₹30-50 per module, they’re one of the cheapest sensors available and a staple of robotics competitions and college projects across India. This guide covers the working principle, wiring, and complete builds for line follower robots and object detection systems.

Table of Contents

  • How IR Obstacle Sensors Work
  • Types of IR Sensors
  • Arduino Wiring and Basic Code
  • Line Follower Robot Project
  • Object Detection Applications
  • Calibration and Troubleshooting
  • Frequently Asked Questions

How IR Obstacle Sensors Work

An IR obstacle sensor module has two components: an IR LED (transmitter) that emits infrared light at ~940 nm wavelength, and a photodiode or phototransistor (receiver) that detects reflected IR light. When an object is within range, IR light bounces off it and reaches the receiver. An LM393 comparator on the module converts this to a digital output.

Key characteristics:

  • Detection range: 2-30 cm (adjustable via potentiometer)
  • Output: Digital (LOW when object detected, HIGH when clear) — note: this is inverted on some modules
  • Angle: ~35° detection cone
  • Response time: <2 ms

Colour Sensitivity

IR sensors are affected by surface colour. White surfaces reflect IR light well (strong signal = object detected at longer range). Black surfaces absorb IR light (weak signal = object not detected or detected only at very close range). This colour sensitivity is actually useful — it’s what makes line-following possible.

Types of IR Sensors

Single IR Obstacle Sensor

The standard module with one IR LED and one receiver. Used for proximity detection, obstacle avoidance, and single-point line detection. Cost: ₹30-50.

IR Line Tracking Sensor (TCRT5000)

The TCRT5000 is a reflective optical sensor in a compact package. It’s more precise than generic IR modules for line following because the emitter and detector are close together and shielded from ambient light. Available as single modules or pre-built arrays of 3-5 sensors on one PCB.

Multi-Channel IR Array

3-sensor or 5-sensor arrays on a single board, designed specifically for line-following robots. The array gives you the line position (left, centre, right) in one reading. A 5-sensor array also detects intersections and line width.

🛒 Recommended: Browse IR sensors and line tracking modules at Zbotic — Single sensors, TCRT5000 modules, and multi-channel arrays for robotics projects.

Arduino Wiring and Basic Code

Sensor Pin Arduino Pin
VCC 5V
GND GND
OUT D2
const int irSensor = 2;
const int led = 13;

void setup() {
  Serial.begin(9600);
  pinMode(irSensor, INPUT);
  pinMode(led, OUTPUT);
}

void loop() {
  if (digitalRead(irSensor) == LOW) {
    // Object detected (most modules output LOW on detection)
    digitalWrite(led, HIGH);
    Serial.println("Object detected!");
  } else {
    digitalWrite(led, LOW);
    Serial.println("Clear");
  }
  delay(100);
}

Line Follower Robot Project

A line follower robot uses IR sensors to detect a dark line (black tape) on a light surface (white floor). The sensor reports LOW over the black line (IR absorbed, no reflection) and HIGH over the white surface (IR reflected back).

Components

  • Arduino Uno/Nano — ₹250-400
  • 3-channel IR sensor array — ₹80-120
  • L298N motor driver — ₹120
  • 2x DC geared motors with wheels — ₹200
  • Robot chassis — ₹150
  • Battery pack (4x AA or 7.4V Li-ion) — ₹100-300
  • Total: ₹900-1,400
// 3-Sensor Line Follower
const int LEFT_SENSOR = 2;
const int CENTRE_SENSOR = 3;
const int RIGHT_SENSOR = 4;

// L298N motor driver pins
const int ENA = 5, IN1 = 6, IN2 = 7;   // Left motor
const int ENB = 10, IN3 = 8, IN4 = 9;  // Right motor
const int SPEED = 150; // 0-255

void setup() {
  pinMode(LEFT_SENSOR, INPUT);
  pinMode(CENTRE_SENSOR, INPUT);
  pinMode(RIGHT_SENSOR, INPUT);
  pinMode(ENA, OUTPUT); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT);
  pinMode(ENB, OUTPUT); pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT);
}

void loop() {
  bool left = (digitalRead(LEFT_SENSOR) == LOW);   // On line?
  bool centre = (digitalRead(CENTRE_SENSOR) == LOW);
  bool right = (digitalRead(RIGHT_SENSOR) == LOW);

  if (centre && !left && !right) {
    // Line is centred - go straight
    moveForward(SPEED, SPEED);
  } else if (left && !right) {
    // Line drifted left - turn left
    moveForward(SPEED / 3, SPEED);
  } else if (right && !left) {
    // Line drifted right - turn right
    moveForward(SPEED, SPEED / 3);
  } else if (left && right) {
    // Intersection or wide line - go straight
    moveForward(SPEED, SPEED);
  } else {
    // Lost the line - stop or search
    moveForward(0, 0);
  }
}

void moveForward(int leftSpeed, int rightSpeed) {
  analogWrite(ENA, leftSpeed);
  analogWrite(ENB, rightSpeed);
  digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH); digitalWrite(IN4, LOW);
}

For smoother line following, upgrade to a 5-sensor array and use PID control. The 5-sensor setup lets you calculate a precise “line position” value (from -2 to +2), which feeds into a PID algorithm that produces proportional motor speed adjustments instead of simple left/right/straight decisions.

🛒 Recommended: HC-SR04 Ultrasonic Sensor — Add obstacle avoidance to your line follower so it stops before hitting objects on the track.

Object Detection Applications

Edge Detection for Robots

Point an IR sensor downward at the floor. When the robot reaches a table edge or stair drop, the sensor loses the floor reflection and outputs HIGH. This prevents the robot from falling off surfaces — essential for table-top robots and Roomba-style cleaners.

Object Counter

Mount an IR sensor at conveyor belt height. Each time an object passes, the sensor triggers. Count the transitions for production counting, visitor counting, or inventory tracking.

Touchless Switch

Use an IR sensor as a proximity trigger for contactless switching. Wave your hand within range to toggle a light, fan, or door mechanism. Useful for kitchen switches (when hands are dirty), public restrooms, and workshops.

🛒 Recommended: LM35 Temperature Sensor — Add temperature monitoring to your robot to detect motor overheating during extended line-following runs.

Calibration and Troubleshooting

  • Adjust the potentiometer with the sensor facing your target surface at the desired detection distance. Turn slowly until the indicator LED just switches — that’s your threshold.
  • Ambient light interference: Sunlight contains IR that can overwhelm the sensor’s IR LED. Use indoors or shield the sensor with a tube. For outdoor line followers, use a shroud around each sensor.
  • Surface matters: Glossy or reflective floors cause specular reflection that can confuse the sensor. Matte surfaces work best. For line-following tracks, use black electrical tape on white chart paper — this provides the strongest contrast.
  • Height calibration: For line followers, mount the sensor 5-15 mm above the surface. Too close and it always detects; too far and it misses the line.

Frequently Asked Questions

How many IR sensors do I need for a line follower robot?

Minimum 2 (left and right of centre — basic left/right correction). Recommended 3 (adds centre detection for straight-line tracking). Ideal 5 (enables PID control and intersection detection). Competition robots often use 7-8 sensors for maximum precision.

Can IR sensors detect transparent objects?

No. Transparent objects (glass, clear plastic, water) pass IR light through them instead of reflecting it. The sensor sees no reflection and reports “no object.” For transparent object detection, use ultrasonic or capacitive sensors instead.

Why does my line follower work indoors but fail outdoors?

Sunlight contains strong IR radiation that saturates the receiver, making it unable to distinguish the sensor’s IR LED reflection. Solutions: (1) Add a shroud/tube around each sensor to block ambient light, (2) increase IR LED power by reducing the series resistor, (3) use sensors with modulated IR (like TSOP receivers) that reject DC ambient light.

Can I use these sensors for long-range detection?

Standard IR obstacle sensors work up to 30 cm. For longer range (1-5m), use Sharp GP2Y0A21 analogue IR sensors (good to 80 cm) or upgrade to ultrasonic (HC-SR04, 400 cm) or LiDAR (TFmini, 1200 cm).

Conclusion

IR obstacle sensors are the simplest, cheapest, and most versatile detection modules for Arduino robotics. A ₹30-50 sensor and 10 lines of code give you obstacle detection, line following, edge detection, or object counting. For competitive line-following robots, invest in a 5-sensor TCRT5000 array and implement PID control — the improvement in speed and accuracy over basic 2-sensor designs is dramatic.

Find IR sensors, sensor arrays, and robotics kits at Zbotic’s sensor collection.

Tags: Arduino, ir sensor, line follower, Robot, Sensors
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
UV Index Monitor: Sunburn Prot...
blog uv index monitor sunburn protection system for indian outdoors 612845
blog noise level monitor decibel meter for industrial and urban use 612849
Noise Level Monitor: Decibel M...

Related posts

Svg%3E
Read more

Encoder Module: Position and Speed Measurement with Arduino

April 1, 2026 0
A rotary encoder converts the angular position and rotation speed of a shaft into electrical signals that Arduino can count... Continue reading
Svg%3E
Read more

Rain Sensor and Raindrop Detection Module: Arduino Guide

April 1, 2026 0
A rain sensor module detects the presence of water droplets on its surface, giving Arduino a simple signal to trigger... Continue reading
Svg%3E
Read more

LiDAR Sensor TFmini: Distance Measurement Beyond Ultrasonic

April 1, 2026 0
When ultrasonic sensors hit their limits — range too short, accuracy too coarse, outdoor sunlight causing interference — LiDAR sensors... Continue reading
Svg%3E
Read more

Pressure Sensor BMP280: Weather Station and Altitude Meter

April 1, 2026 0
The BMP280 barometric pressure sensor by Bosch measures atmospheric pressure with ±1 hPa accuracy and temperature with ±1°C precision. These... Continue reading
Svg%3E
Read more

Colour Sensor TCS3200: Sorting Machine Project with Arduino

April 1, 2026 0
The TCS3200 colour sensor detects the colour of objects by shining white LEDs onto a surface and measuring the reflected... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now