Infrared Line Tracking Sensor
The infrared line tracking sensor uses the TCRT5000 infrared reflection sensor, a photoelectric sensor that combines both emitting and receiving functions. It is commonly used in projects such as robots to detect paths or boundaries on surfaces. When the color of the surface changes (typically a black line on a white background), the reflective properties of the infrared light are altered, causing the infrared receiver to detect different signals. The sensor is designed for a reflection distance of 1mm to 25mm. It features an M3 mounting hole for easy installation and direction adjustment. The sensor uses the LM393 comparator with a wide voltage range, providing clean signals, good waveform quality, and strong driving capability, supporting up to 15mA. This sensor can be used in robot obstacle avoidance, as well as for line-following tasks, capable of detecting black lines on a white background or white lines on a black background. It is an essential sensor for line-following robots.
Module Source
Purchase Link:
https://item.taobao.com/item.htm?spm=a1z10.3-c-s.w4002-24706531953.16.60226a4brYl7Cq&id=522577760881
Baidu Netdisk Download Link:
https://pan.baidu.com/s/1Tjd2iHMtNVgwhqqCU_PmTQ
Password: 8zul
Specifications
Operating Voltage: 3.3V-5V
Detection Reflection Distance: 1mm~25mm
Output Method: DO interface for digital output; AO interface for analog output Reading Method: ADC
Pin Count: 4 Pin (2.54mm pitch header)
Hardware Connection
- The Vcc terminal of the sensor is connected to the 5V supply of the development board;
- The GND terminal is connected to the GND of the development board;
- AO (analog signal output) to the A0 analog input pin of the development board;
- DO (digital signal output) connected to the development board pin 8;
Usage Method
Compile and upload the following code to the development board.
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: April 8, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
int IR_AO_Pin = A0; // 定义红外循迹传感器的AO连接到开发板的A0引脚
int IR_DO_Pin = 8; // 定义红外循迹传感器的DO连接到开发板的8号引脚
int IRValue = 0; // 用于存储红外循迹返光强度值的变量
#define ADC_MAX_VALUE 1023 //ADC的最大采集值
void setup() {
Serial.begin(9600); // 开始串行通讯,设置波特率为9600
pinMode(IR_DO_Pin, INPUT_PULLUP);
}
void loop() {
// 读取按钮的状态
int IRState = digitalRead(IR_DO_Pin);
if (IRState == LOW) {
Serial.println("检测到线");
} else {
Serial.println("未检测到线");
}
IRValue = analogRead(IR_AO_Pin); // 读取A0引脚的电压值
Serial.print("返光度: ");
Serial.println(IRValue); // 将读取的值发送到电脑的串行监视器
delay(1000); // 延时1秒
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Usage Method
Place a black obstacle and a non-black obstacle under the sensor. When the black obstacle is detected, the serial output will be "Line detected." When a non-black obstacle is detected, the serial output will be "No line detected."