Tutorial

Table Of Contents
72
13 Line Tracking
Some of our robot products are equipped with a three-channel infrared line patrol module. The line
patrol module is converted to the robot's line patrol function design. The three-channel infrared line patrol
module contains 3 groups of sensors, where each group of sensors consists of an infrared emitting LED and an
infrared sensor photoelectric Transistor composition, the robot determines whether there is a line detected by
detecting the infrared light intensity detected by the infrared sensor phototransistor. It can detect the white line
(reflected infrared light) on a black background (non-reflected infrared light), and can also detect a white
background The black line on (reflects infrared light) (does not reflect infrared light).
Since the Raspberry Pi can only read digital signals, the three-channel infrared tracking module is
equipped with a potentiometer. You can use a cross screwdriver to adjust the potentiometer on the infrared
tracking module to adjust the sensitivity of the infrared sensor phototransistor.
Our program defaults to finding black lines on a white background (reflecting infrared light) (not
reflecting infrared light).
Before using the three-channel infrared line patrol module, you need to connect it to the Tracking
interface on Motor HAT using a 5-pin cable.
The three-way infrared line patrol module has an arrow pattern on the back of the sensor. The direction
of the arrow is the direction of the robot.
The codes of the three-channel infrared line patrol module are as follows:
import RPi.GPIO as GPIO
import time
# Hunt module output pin
line_pin_right = 19
line_pin_middle = 16
line_pin_left = 20
'''
Initialize your GPIO port related to the line patrol module
'''
def setup():
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(line_pin_right,GPIO.IN)