กลับหน้าหลัก
views
How to Use TCRT5000 Infrared Line Tracking Sensor with Arduino
Last updated on

How to Use TCRT5000 Infrared Line Tracking Sensor with Arduino


How to Use TCRT5000 Infrared Line Tracking Sensor with Arduino

The TCRT5000 is an infrared reflective sensor that detects surfaces by measuring light reflection. White surfaces reflect IR light back to the receiver, outputting a digital HIGH (1), while black surfaces absorb the light, outputting LOW (0). This behavior makes it ideal for line-following robots and basic object detection projects.

Diagram of TCRT5000 module showing the IR LED emitter, phototransistor receiver, and sensitivity potentiometer

Required Components

  • Arduino UNO R3 with USB cable
  • TCRT5000 Infrared Line Tracking Sensor Module
  • MB-102 Breadboard (830 points)
  • Male-to-male jumper wires, 20 cm (5 pieces)
  • White paper and black electrical tape (for testing)
  • Optional: Red 5mm LED with 220Ω resistor for status indicator

Wiring Diagram

Connect the TCRT5000 module to your Arduino UNO as follows

Circuit diagram showing Arduino UNO pins 5V, GND, and Pin 2 connected to TCRT5000 module VCC, GND, and OUT pins
ArduinoTCRT5000 Module
5VVCC (positive)
GNDGND (negative)
Pin 2OUT (signal)

If you want a visible LED indicator, connect an LED in series with a 220Ω resistor between Pin 13 and GND.

Arduino Code Example

Open Arduino IDE, paste the code below, select Board as Arduino UNO, and upload.

// TCRT5000 Digital Output Reading
// Connect OUT pin to Arduino Pin 2


const int sensorPin = 2;  // Signal pin from TCRT5000 OUT
const int ledPin = 13;    // Built-in LED on Pin 13

void setup() {
  Serial.begin(9600);
  pinMode(sensorPin, INPUT);
  pinMode(ledPin, OUTPUT);
  Serial.println("TCRT5000 Line Tracking Test");
  Serial.println("===========================");
}

void loop() {
  int sensorValue = digitalRead(sensorPin);

  // Display value on Serial Monitor
  Serial.print("Digital Output: ");
  Serial.println(sensorValue);

  // White surface -> value = 1
  // Black line   -> value = 0
  if (sensorValue == 1) {
    Serial.println(">> White surface detected");
    digitalWrite(ledPin, HIGH);
  } else {
    Serial.println(">> Black line detected");
    digitalWrite(ledPin, LOW);
  }

  delay(500);
}

Testing Procedure

  1. Open Serial Monitor (Tools > Serial Monitor)
  2. Set Baud Rate to 9600
  3. Hold the sensor above white paper with the sensing face pointing down
  4. Observe the output shows 1 with message “White surface detected”
  5. Slide the sensor over black electrical tape, the value changes to 0 showing “Black line detected”
  6. Slide back to white paper, the value returns to 1
Illustration showing sensor reading white paper (output = 1) and black tape (output = 0) on Serial Monitor

Testing Object Detection

The TCRT5000 can also detect objects using the same reflective principle

  1. Hold the sensor above a desk surface until Serial Monitor shows 1
  2. Bring an object close to the sensor, the output changes to 0 when the object blocks the reflected IR
  3. Remove the object, the value returns to 1

The principle is straightforward: when an object blocks the IR light that would normally reflect from a surface, the phototransistor stops receiving a signal and the output changes.

Adjusting Sensitivity

The potentiometer on the TCRT5000 module adjusts detection sensitivity

  • Turn left: Decrease sensitivity (object must be closer)
  • Turn right: Increase sensitivity (detects from farther away)

Note: In environments with fluorescent lighting or sunlight, high sensitivity may cause false triggers. Adjust the potentiometer until the sensor responds reliably without interference.

Summary

The TCRT5000 module is a practical choice for beginner projects involving line detection or object proximity sensing. The wiring is straightforward, the output is digital and clean, and it works well with Arduino without needing extra libraries. You can apply this directly to line-following robots, conveyor belt monitoring, or simple automation systems.

Reference Video

อยากทำโปรเจคแบบนี้?

รับทำโปรเจค Arduino / IoT จบงานไว ส่งงานครบ พร้อมสอน

If you need Arduino project service or urgent IoT development, see full service details on the home page

จ้างทำโปรเจคเลย

ประเมินราคาอัตโนมัติ + Reference Code

ขอให้ AI ประเมินราคาโปรเจคนี้

กรอกข้อมูลให้ครบ ระบบจะสร้างรหัสอ้างอิงและประเมินราคา/ระยะเวลาคร่าว ๆ จากรายละเอียดงาน แล้วให้กด Add LINE พร้อมพิมพ์รหัสนี้เพื่อคุยต่อ

คำถามให้ AI ประเมินแม่นขึ้น

หลังส่งฟอร์ม ระบบจะโชว์ Reference Code ให้ copy แล้วกด Add LINE เพื่อคุยต่อ ข้อมูลส่วนตัวจะไม่ถูกส่งเข้า GA4

ความคิดเห็น

รีวิวจากคนใช้งานจริง

รีวิวจากลูกค้าและคนที่เคยใช้งาน

ถ้าเคยสั่งงาน เคยอ่านหน้านี้แล้วได้ประโยชน์ หรือมีข้อเสนอแนะ ฝากรีวิวไว้ได้เลย

กำลังโหลดรีวิว...