AmpleRobots

Robot Passport · Controls

Line-following robot

Learn feedback control by tuning a robot that follows a track.

A two-wheel robot that reads a line with reflectance sensors and uses proportional and PID control to stay on it.

What you will learn

  • Reflectance sensing
  • Proportional control
  • PID tuning
  • Calibrating sensors

Parts

ComponentQtyPurpose
Small chassis with two geared motors and a caster1Light, low platform that turns tightly.
Reflectance sensor array (3–8 channels)1Detects the dark line against a light floor.
Dual motor driver1Independent speed control of each wheel.
Microcontroller board1Reads sensors and runs the control loop.
Battery pack and switch1Power for motors and controller.
Black electrical tape and white board or paper1Builds the test track.

Generic parts are listed on purpose: choose locally available equivalents that meet the same ratings.

Build steps

  1. Mount the sensor array 3–8 mm above the floor, centred between the wheels and ahead of the axle.
  2. Calibrate: sweep the robot across the line and store the minimum and maximum reading of each sensor.
  3. Compute a line position (e.g. a weighted average) where 0 means centred.
  4. Start with proportional control only: steering = Kp × position. Increase Kp until the robot follows gentle curves.
  5. Add derivative (Kd) to reduce wobble, then a small integral (Ki) only if the robot drifts on long curves.

Test protocol

Goal: Find the fastest speed at which the robot completes the track without losing the line.

Setup: Build a closed loop of about 3 m with two gentle curves and one 90° turn using 19 mm tape.

  1. Record Kp, Ki, Kd and base speed for every run.
  2. Run three laps at each speed setting, increasing speed in small steps.
  3. Count line losses and measure lap time.

Record for every run:

  • Base speed
  • Kp / Ki / Kd
  • Lap time (s)
  • Line losses per lap
  • Lighting conditions

Measured results for this reference design will be published here with their test conditions. Submitting your own results opens with member accounts.

Safety

  • Disconnect power before adjusting sensor height.
  • Test on the floor or a table with edges guarded.

Take it further

  • Add a junction detector and solve a simple maze.
  • Store tuning values so they survive a reset.
  • Compare P-only and PID lap times in a chart.

Stuck on this build?

Ask the AmpleRobots team. Build threads in RoboForum, linked to each Passport, open with member accounts.

Ask a question →