Projects with Python·Tutorial 4 of 5

Line Follower in Python

Advanced

Program a line-following robot in Python. Read both TCRT5000 sensors, classify the robot's position relative to the line, and steer the motors accordingly — four states, clean functions, smooth following.

40 min5 steps
Line SensorMotorsSteeringRobotFunctionsProjectAdvanced
0 of 5 steps

Step 1 of 5

Connect your board

Power on your Beaver Board — the OLED will show a PIN code. Click Connect in the toolbar, choose Connect via Bluetooth, and select your board. If it's your first time, enter the PIN shown on the screen.

The TCRT5000 sensors point downward from the chassis — left on GP4, right on GP5. Place the robot over your line track.

Use black electrical tape on white paper or card. Keep curves gentle — a loop about 50–70 cm wide works well. Hold the board 5–10 mm above the surface.