Sign in to save

Bookmark this page so you can find it later.

Sign in to save

Bookmark this page so you can find it later.

A line-following robot is a small mobile robot that uses sensors to detect a dark line and adjust its motors to stay on track. This project connects physics, electronics, coding, and engineering design in one hands-on build. It is useful because the same ideas appear in factory robots, delivery vehicles, and automated machines that follow paths or detect edges.

For grades 7 to 12, it is a manageable project that still shows real feedback control.

Key Facts

  • Two IR sensors can detect line position by comparing left and right reflected light values.
  • If left sensor sees black and right sensor sees white, turn left by slowing or reversing the left motor.
  • If right sensor sees black and left sensor sees white, turn right by slowing or reversing the right motor.
  • Bang-bang control uses simple on or off decisions, such as error < 0 turn left and error > 0 turn right.
  • PID control can be written as correction = Kp e + Ki ∫e dt + Kd de/dt.
  • Motor speed depends on PWM duty cycle, with duty cycle = on time / total period.

Vocabulary

IR sensor
An infrared sensor shines infrared light and measures how much light reflects back from a surface.
Motor driver
A motor driver is a circuit that lets a low-power controller safely control higher-current motors.
Calibration
Calibration is the process of measuring sensor readings on known surfaces so the robot can make accurate decisions.
Control loop
A control loop repeatedly senses, decides, acts, and checks again to reduce an error.
PWM
Pulse width modulation controls average motor power by rapidly switching voltage on and off.

Common Mistakes to Avoid

  • Placing the sensors too far apart makes the robot lose the line because neither sensor may detect the edge during a turn.
  • Skipping calibration is wrong because black tape, white paper, room lighting, and sensor height can all change the readings.
  • Connecting motors directly to a microcontroller pin is unsafe because motors need more current than most controller pins can supply.
  • Using full speed before testing control logic causes overshooting because the robot moves farther before each sensor update can correct it.

Practice Questions

  1. 1 A robot reads 820 on white paper and 230 on black tape from one IR sensor. Choose a threshold halfway between them and state whether a reading of 500 should be treated as black or white.
  2. 2 A PWM signal has a period of 20 ms and is on for 6 ms. Calculate the duty cycle as a percentage and explain whether this is closer to low, medium, or high motor power.
  3. 3 A robot wiggles rapidly left and right while following the line. Explain how changing sensor spacing, speed, or control logic could reduce this motion.