Summary
Learn how to use a TCRT5000 5-channel IR sensor array for line-following robots. Explore the pinout, Arduino connections, sensor calibration, mounting height, PID tuning and common troubleshooting fixes.
A 5-channel TCRT5000 IR sensor array helps a line-following robot detect whether it is drifting left or right of a track. Each sensor reads reflected infrared light from the surface below it, and the controller combines the five outputs to estimate the line’s position. With correct mounting, calibration and PID tuning, this gives smoother tracking than a basic two-sensor setup.
For a practical build, the 5 Channel IR Infrared CTRT5000 Line Detection Module can connect to a microcontroller such as an Arduino and provide five tracking signals for the robot’s control logic.
What Is a TCRT5000 5 Channel Sensor?
A TCRT5000 5-channel IR sensor array is a line-detection module that combines five reflective infrared sensing points on one board. It is commonly used in line follower robots, where it helps the controller detect a dark line against a lighter background—or a light line against a dark surface.
Each sensing point contains an infrared emitter and a receiver. The emitter sends infrared light toward the floor, while the receiver detects how much light returns. Because different surfaces reflect different amounts of infrared light, the sensor can distinguish changes in surface reflectivity.
A five-sensor array gives the robot more information about the line’s position than a single sensor or a basic two-sensor arrangement. For example, if the centre sensor detects the line, the robot is likely aligned. If the left-side sensors detect it, the robot needs to steer left. If the right-side sensors detect it, the robot needs to steer right.
The five readings can also help the controller recognise when the robot is approaching a curve, crossing an intersection or losing the line. The exact behaviour depends on the sensor output polarity and the logic implemented in the code.
How Does a 5 Channel IR Sensor Array Work?
The sensor array works by detecting reflected infrared light and converting the readings into electrical outputs that a microcontroller can interpret.
The basic process is:
-
IR emission: Each sensor’s infrared LED emits light toward the track.
-
Surface reflection: A light surface usually reflects more infrared light, while a dark line often reflects less.
-
IR detection: The receiver responds to the reflected light.
-
Signal generation: The module produces an output for each sensing channel.
-
Line-position estimation: The controller combines the five outputs to decide whether to move straight or correct its direction.
-
Motor control: The microcontroller sends commands to the motor driver to adjust the robot’s movement.
The output logic is not universal across all IR modules. Depending on the board’s comparator and wiring, a channel may produce LOW over a dark line and HIGH over a light surface, or the reverse. Test the actual module before writing the final control logic.
A five-channel array is particularly useful because it gives the controller more information about the line’s position. Rather than only knowing that the robot has drifted, the controller can estimate how far the line is from the centre and adjust its steering accordingly.
TCRT5000 5 Channel Sensor Pinout and Connections
The five-channel module typically has a power connection, a ground connection and five individual sensor outputs.
|
Pin |
Function |
Connection |
|---|---|---|
|
VCC |
Power input |
Compatible 3.3V–5V supply, as specified for the module |
|
GND |
Ground |
Microcontroller GND |
|
OUT1 |
Sensor channel 1 |
Microcontroller input |
|
OUT2 |
Sensor channel 2 |
Microcontroller input |
|
OUT3 |
Sensor channel 3 |
Microcontroller input |
|
OUT4 |
Sensor channel 4 |
Microcontroller input |
|
OUT5 |
Sensor channel 5 |
Microcontroller input |
The exact pin order can vary between board revisions. Check the labels printed on your module before connecting the wires. Do not rely on a generic pinout image if it does not match your specific board.
For an Arduino Uno, you can connect the five outputs to five digital input pins. The following example uses D2 through D6:
|
Sensor array |
Arduino Uno |
|---|---|
|
VCC |
5V, if supported by your module |
|
GND |
GND |
|
OUT1 |
D2 |
|
OUT2 |
D3 |
|
OUT3 |
D4 |
|
OUT4 |
D5 |
|
OUT5 |
D6 |
This is an example mapping, not a mandatory pin arrangement. You can choose other suitable digital pins, provided the code uses the same pin assignments.
What to check before powering the module
-
Confirm the board’s supported supply voltage.
-
Make sure the sensor and Arduino share a common ground.
-
Check that each output connects to a separate input.
-
Keep the sensor board level and secure beneath the front of the robot.
-
Test the output from each sensor before connecting the motor-control logic.
Image placement suggestion: Add a clear, existing product image showing the board’s pin labels. Use alt text such as: TCRT5000 5 channel IR sensor array pinout showing VCC, GND and five sensor outputs.
Mounting Height and Sensor Placement
Mounting height has a direct effect on how reliably an IR array detects a line. If the board is too far from the floor, the difference between reflected signals may become less distinct. If it is too close, uneven flooring, chassis movement or contact with the track can cause inconsistent readings.
A practical starting height is around 1–2 cm above the track, then adjust it based on the module’s specifications and test results. The target module’s product information lists a short detection range, so verify its actual response at your chosen height rather than assuming every TCRT5000 board behaves identically.
For reliable tracking:
-
Keep the sensor board parallel to the floor.
-
Position the array ahead of the wheels so the robot has time to react to curves.
-
Ensure all five sensors have a similar distance from the track.
-
Avoid excessive chassis vibration or a loose sensor mount.
-
Test on the same type of surface the robot will use during operation.
The track itself also matters. Very glossy floors, direct sunlight, uneven surfaces and low contrast between the line and background can affect reflected infrared light. Use a clearly defined track during initial calibration.
Image placement suggestion: Add an actual photo of the sensor mounted beneath a line follower robot, with the sensor array facing the floor. Suggested alt text: Correct mounting height and downward-facing placement of a five-channel IR sensor array on a line follower robot.
Wiring the Sensor Array to a Line Follower Robot
A working line follower needs more than a sensor. The complete system usually includes a microcontroller, a five-channel IR array, a motor driver, two DC gear motors, a chassis and a suitable battery.
The sensor array tells the controller where the line is. The controller processes those readings and sends direction and speed commands to the motor driver. The motor driver supplies the current required by the motors; the Arduino should not drive the motors directly.
A typical setup includes:
-
Controller: Arduino Uno or a compatible microcontroller
-
Motor driver: L298N motor driver module
-
Motors: BO geared motors
-
Power source: A battery suited to the motors and driver, with appropriate power regulation for the electronics
Connect the sensor’s five outputs to the controller’s input pins. Connect the controller’s motor-control pins to the motor driver, then connect the motors to the driver’s output terminals. Follow the wiring instructions for the specific motor driver and power supply.
Keep motor power and logic power requirements in mind. Motors can create electrical noise and voltage dips, which may cause unstable sensor readings or reset the controller. Use a suitable supply, connect grounds correctly and keep power wiring secure.
Reading the Five Sensors with Arduino
Before adding PID control, verify that every sensor responds as expected. A simple test sketch can display the five digital readings in the Serial Monitor.
The example below assumes that the sensor outputs are digital and uses the pin mapping described above.
const int sensorPins[5] = {2, 3, 4, 5, 6};
void setup() {
Serial.begin(9600);
for (int i = 0; i < 5; i++) {
pinMode(sensorPins[i], INPUT);
}
}
void loop() {
for (int i = 0; i < 5; i++) {
Serial.print(digitalRead(sensorPins[i]));
if (i < 4) {
Serial.print(" ");
}
}
Serial.println();
delay(100);
}
Upload the sketch, open the Serial Monitor and slowly move the sensor array over the line. Watch how each channel changes as it passes from the background to the line.
For a five-sensor array, the displayed values represent the channels from OUT1 through OUT5. Determine which value corresponds to the dark line and which corresponds to the background. Some modules use the opposite output polarity from others, so confirm this before writing the robot’s steering logic.
If a channel never changes, check the wiring, supply voltage, mounting height and sensor response. If readings change unpredictably, try reducing ambient light interference, securing the board and checking the track surface.
From Bang-Bang to PID Control
A line follower can use simple Bang-Bang control or a more refined PID algorithm. The best approach depends on the robot’s speed, track complexity and the level of control you need.
Bang-Bang control
Bang-Bang control uses straightforward decisions. If the line is detected on the left, the robot turns left; if it is detected on the right, it turns right. When the centre sensor detects the line, the robot moves straight.
This is easy to implement and is often sufficient for a beginner project. However, the robot may repeatedly swing from side to side, particularly at higher speeds or on sharp curves.
PID control
PID stands for Proportional, Integral and Derivative. Instead of making only a few fixed steering decisions, a PID controller calculates a correction based on the estimated position error.
-
Proportional (P): Responds to the current error. A larger deviation produces a stronger correction.
-
Integral (I): Accumulates error over time and can help correct persistent bias.
-
Derivative (D): Responds to how quickly the error changes, helping reduce overshoot and oscillation.
For a line follower, the controller first converts the five sensor readings into a line-position estimate. It compares that estimate with the desired centre position and calculates the correction. The correction can then be applied to the left and right motor speeds.
A five-channel array can provide more position information than a two-sensor arrangement, making it useful for smoother steering. However, the quality of the result still depends on calibration, code, motor response and track conditions.
A simple position estimate
If your sensor outputs are digital, you can assign a position weight to each channel. For example, use weights of -2, -1, 0, +1 and +2 from left to right. When a sensor detects the line, its weight contributes to the estimated position.
For a simplified example:
|
Sensor detecting the line |
Estimated position |
|---|---|
|
Far left |
-2 |
|
Left |
-1 |
|
Centre |
0 |
|
Right |
+1 |
|
Far right |
+2 |
The sign convention is arbitrary: you can reverse it if your sensor order or steering convention is opposite. If multiple sensors detect the line, combine their weights to estimate the line’s position. For a digital array, the result is an approximation rather than a continuous measurement.
The controller then calculates:
-
Error: Estimated line position minus the desired centre position.
-
Correction: A PID calculation based on the current error, accumulated error and change in error.
-
Motor commands: Adjust the left and right motor speeds in opposite directions to steer toward the line.
For example, if the line moves toward the right side of the array, the controller can increase the right-versus-left steering correction according to its chosen sign convention. Always test the correction direction at low speed. If the robot steers away from the line, reverse the sign or swap the motor commands as appropriate.
A key limitation is that a digital five-channel array only reports discrete channel states. If your particular board exposes analog readings instead, you can use those values to estimate line position more finely, provided the hardware and microcontroller support analog input. Confirm the output type of your exact board before choosing the algorithm.
PID tuning table
|
Parameter |
What it changes |
If the value is too high |
|---|---|---|
|
Kp |
Strength of correction for current error |
Robot may oscillate around the line |
|
Ki |
Correction for persistent error |
Correction can build up and cause overshoot |
|
Kd |
Response to changes in error |
Noise can cause excessive or jittery correction |
Start with Ki set to zero. Increase Kp gradually until the robot follows the line but begins to show noticeable oscillation. Then reduce Kp slightly and add a small amount of Kd to damp the oscillation. Add Ki only if the robot shows a persistent bias that P and D do not correct.
Tune at a low motor speed first, then increase speed gradually. A setting that works on a straight track may not work well on sharp bends. Re-test after changing the sensor height, battery, motor or track surface.
Troubleshooting a 5 Channel Line Follower Sensor
If the robot fails to follow the track consistently, test the sensor readings before changing the PID values. Many line-following problems come from mounting, wiring or incorrect assumptions about sensor polarity.
|
Problem |
Likely cause |
What to check |
|---|---|---|
|
Robot does not detect the line |
Sensor too high, poor contrast or incorrect wiring |
Lower the array within its recommended range and test each channel |
|
Robot turns away from the line |
Output polarity or steering logic is reversed |
Confirm the line-detection state and reverse the correction sign if needed |
|
Robot oscillates from side to side |
Excessive correction, high speed or poor PID tuning |
Reduce speed, adjust Kp and tune Kd gradually |
|
One sensor never changes |
Faulty connection, damaged channel or poor alignment |
Inspect the pin, test the channel and check sensor height |
|
Readings change under bright light |
Ambient IR interference or reflective flooring |
Shade the sensor, reposition it and test on a suitable track |
|
Robot loses the line on curves |
Excessive speed, limited correction or poor sensor placement |
Slow down, move the array forward if practical and refine the control logic |
|
Arduino resets when motors start |
Power supply dips or motor electrical noise |
Check the battery, power distribution, grounding and decoupling |
How to check sensor calibration
-
Place the robot on the track with its motors disabled.
-
Observe all five sensor outputs on the background.
-
Move the array so the line passes beneath each sensor in turn.
-
Record which state represents the line and which represents the background.
-
Confirm the controller’s left-to-right sensor order.
-
Test steering corrections with the wheels lifted or the robot moving slowly in a safe area.
If the robot uses adjustable sensitivity controls, change them in small steps and repeat the test. Not every five-channel board has the same adjustment hardware, so use the controls provided on your specific model.
Applications of a Five-Channel IR Sensor Array
A five-channel IR sensor array is useful whenever a small robot needs to follow a marked path or detect where a line sits relative to its body.
Common applications include:
-
Line follower robots: Follow black or white tracks in robotics competitions and educational projects.
-
Maze-solving robots: Detect track branches and intersections when combined with suitable navigation logic.
-
Grid navigation: Help a robot recognise line crossings and make programmed turns.
-
Educational robotics: Demonstrate digital inputs, sensor calibration, motor control and feedback systems.
-
Automated guided prototypes: Explore basic path-following concepts in controlled environments.
The sensor array is a tracking component, not a complete navigation system. It cannot independently determine its location or plan a route. The controller’s software must interpret the sensor states and decide what the robot should do next.
For a complete build, use the sensor array alongside a compatible motor driver and suitable motors. You can also follow Robocraze’s step-by-step line follower robot guide for broader assembly and programming guidance.
Why Choose Five Sensors Instead of Two?
A two-sensor setup is simple and can work well on straightforward tracks, but it provides limited information about where the line sits between the sensors. A five-channel array adds intermediate detection points, helping the controller estimate line position more precisely.
|
Feature |
Two-sensor setup |
Five-sensor setup |
|---|---|---|
|
Hardware complexity |
Lower |
Slightly higher |
|
Input signals |
Two |
Five |
|
Line-position information |
Limited |
More detailed |
|
Curve response |
Depends heavily on logic and spacing |
More opportunities to detect deviation earlier |
|
Control options |
Basic steering logic |
Basic logic or weighted position estimation for PID |
|
Programming effort |
Usually simpler |
Requires handling more sensor combinations |
Five sensors do not automatically guarantee better performance. A poorly mounted or poorly calibrated five-channel array may perform worse than a well-tuned two-sensor system. The advantage comes from using the extra readings effectively.
For a beginner project, start by getting reliable sensor readings and simple steering working. Once the robot can follow a line consistently, move to weighted position estimation and PID control.
Conclusion
A TCRT5000 5-channel IR sensor array gives a line-following robot five sensing points to detect a track and estimate its position. Correct pin connections, a stable mounting height, reliable sensor calibration and appropriate motor control are the foundations of accurate tracking.
Start with a simple sensor test, confirm whether each output is HIGH or LOW over the line, and get basic steering working before tuning PID. Once the robot follows the track reliably at low speed, adjust the control parameters and gradually increase speed.
For a DIY line follower build, the 5 Channel IR Infrared CTRT5000 Line Detection Module is a practical starting point. Pair it with a compatible microcontroller, motor driver and geared motors to build and experiment with your own tracking robot.