Lesson 09: Line Following Robot

Course: Robotics & Arduino Lesson 09 of 12

Use IR sensors to read a line and build a proportional steering algorithm.


Learning Objectives

By the end of this lesson you will be able to:


Hardware Required

See the Kit List on the course overview page for the full component list. For this lesson you will specifically need the components mentioned in the steps below.


Step-by-Step Guide

  1. IR sensor module basics: emitter + detector. When IR reflects off white: HIGH. Black absorbs: LOW.
  2. Wire two IR sensors: left sensor → A0, right sensor → A1.
  3. Print both sensor readings to Serial Monitor. Place over white and black surfaces to observe.
  4. Mount sensors on front of chassis, 1–2cm above the ground.
  5. Logic: both white = straight; left on black = turn left; right on black = turn right; both black = stop or turn.
  6. Implement basic line following: if(left==LOW && right==HIGH) { turnLeft(); } else if(right==LOW && left==HIGH) { turnRight(); } else { forward(); }
  7. Tune motor speeds so turns are responsive but not too sharp.
  8. Test on a black-tape track on white paper. Adjust sensor height and speed.
  9. Add a third centre sensor for smoother tracking on complex curves.
  10. Add a crossroads detection: all three sensors on black = stop for 1 second then continue.

Extension Challenges


Review Questions

  1. Explain in your own words what this lesson’s main component does.
  2. What would happen if you changed one key parameter in your sketch?
  3. How does this lesson’s content connect to the final robot build in Lesson 12?

Troubleshooting Tips


Back to Course Next: Lesson 10