MyRoboPath
Mobile Robots & AMRs
Est. 6 Hours
Budget: $30 - $45

Autonomous Line-Follower Robot with 5-Channel IR Sensor Array

Build a fast line-tracking robot using a 5-sensor infrared reflectance array (TCRT5000) and tuned PID steering control in C++.

Line followers are the foundation of industrial Automated Guided Vehicles (AGVs) in Amazon warehouses. This project teaches optical reflectance sensing, digital threshold calibration, and Proportional-Integral-Derivative (PID) steering algorithms to follow high-speed curves and sharp right angles smoothly.

Bill of Materials (BOM) & Components

ComponentSpecificationsQtyEstimated Cost
5-Channel TCRT5000 Infrared Reflectance Sensor BarAdjustable sensitivity potentiometers with digital & analog outputs1$5.00
Micro N20 High-Speed Metal Gearmotors (6V 600RPM)High torque density with brass gearboxes and rubber micro wheels2$9.00
TB6612FNG Dual Motor Driver BoardHigh-efficiency MOSFET H-Bridge (low voltage drop)1$4.50
Arduino Nano or ESP32 MicrocontrollerFast 1kHz PID control loop calculation1$6.00
2S 7.4V 800mAh LiPo Battery & Mini Buck ConverterLightweight high-discharge power source1$12.00

Electrical & Architecture Summary

5 digital IR outputs connect to Arduino A0-A4 pins. TB6612FNG driver receives PWM on D3/D5 and direction pins on D4/D6/D7/D8. IR sensor bar is mounted ~5mm above the track surface.

Figure 4: TCRT5000 5-sensor bar pinout and TB6612FNG motor driver connections.
Figure 4: TCRT5000 5-sensor bar pinout and TB6612FNG motor driver connections.Wiring Schematic

Step-by-Step Assembly & Configuration

1

Chassis Assembly & Sensor Bar Height Tuning

Duration: 2 Hours

Mount the N20 gearmotors near the rear axle. Fix the 5-channel IR sensor bar at the extreme front of the chassis, exactly 4mm - 7mm above the ground.

Checklist:
  • Ensure sensor bar is completely horizontal so all 5 phototransistors receive identical reflected light.
  • Use electrical black tape (19mm width) on a white poster board for the test track.
2

Sensor Calibration & Weighted Error Calculation

Duration: 1.5 Hours

Write calibration code to assign weighted error values (-2, -1, 0, +1, +2) across the 5 sensors depending on which sensors detect the black line.

Checklist:
  • Calculate center line position: `error = (-2*S1) + (-1*S2) + (0*S3) + (1*S4) + (2*S5)`.
  • Verify error output is 0 when the robot is perfectly centered on the line.
3

Implementing and Tuning the PID Steering Loop

Duration: 2.5 Hours

Implement the PID formula: `correction = (Kp * error) + (Kd * dError) + (Ki * integral)`. Apply `base_speed ± correction` to left and right motors.

Checklist:
  • Start with Kp only: increase Kp until the robot follows lines with gentle hunting oscillations.
  • Add Kd to dampen oscillations and handle sharp 90-degree turns smoothly.
Engineering Tip: Too much integral gain (Ki) causes overshoot on fast straightaways—keep Ki very low or zero.