top of page
Writer's pictureRamesh G

TCRT5000 IR Reflective Line Tracking sensor Interface with Arduino


In this tutorial, you will learn how to find black and white line track color using TCRT5000 IR reflective sensor. This IR reflective sensor utilizes a TCRT5000 to detect color and distance. It emits IR and then detects if it receives the echo. This sensor is often used in line following robots, auto data logging on utility meters, because this module can sense if a surface is white or black.


Circuit Diagram

Components Required

Arduino Uno - 1 no

LCD16x2 with I²C module - 1no

TCRT5000 sensor - 1 no


TCRT5000 IR reflex Tracking Sensor Module

The TCRT5000 Sensor is used to detect color and distance. The sensor emits an infrared wave and then receives it. TCRT5000 Infrared Reflective Sensor Module is often used in line following robots and object sorting Robots since this module can sense if a surface is white or black.

The Module Adopts TCRT5000 photoelectric sensor and comparator. It is easy to use, has good stability and anti-interference ability. Its is Perfect for black & white line detection for smart car and has a Black line for low-level output, a white line for high-level output.


Features:

  1. The working voltage: 5V

  2. The output format: digital signal (0 and 1)

  3. A fixed bolt hole for easy installation

  4. Small PCB board size: 3.5cm x 1cm

  5. A single weight: 4.5g

  6. Detector distance: 25mm

  7. Build-in Tcrt5000 Sensor NSOR

Download Refer Datasheet



Installing the Arduino Library

LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library.


Follow the next steps to install those libraries.


In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded.


After installing the required libraries, copy the following code to your Arduino IDE.


Subscribe and Download code.



Arduino Code:

int GND = 5;

int VCC = 6;

int OUT = 7;

#define start 8

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4);



void setup() {


// initialize serial communication at 9600 bits per second:

pinMode(GND, OUTPUT);

pinMode(VCC, OUTPUT);

pinMode(OUT, INPUT);

pinMode(start, INPUT);

digitalWrite(GND, LOW);

digitalWrite(VCC, HIGH);

Serial.begin(9600);

lcd.init(); // initialize the lcd

// Print a message to the LCD.

lcd.backlight();

}


void loop() {


lcd.setCursor(0,0);

lcd.print("TRACKING SENSOR ");


int sensorValue = digitalRead(OUT);

if ((sensorValue == 0)& (digitalRead(start) == HIGH)){

Serial.println("Black color");

lcd.setCursor(0,1);

lcd.print(" BLACK COLOR ");

delay(1000);

}

if ((sensorValue == 1)& (digitalRead(start) == HIGH)){

Serial.println("White color");

lcd.setCursor(0,1);

lcd.print(" WHITE COLOR ");

delay(1000);


}

else

{

lcd.setCursor(0,1);

lcd.print("FIND PATH COLOR ");

delay(100);


}

}

After a successful upload, open the Serial Monitor at a baud rate of 9600. Press the “EN/RST” button on the Arduino Uno board and Open Serial monitor and see the result in Serial monitor.




Recent Posts

See All

Comments


bottom of page