Skip to content
Robotics Intermediate

Line-Following Robot

Autonomous robot that tracks a black line using IR sensors

A two-wheel differential-drive robot that follows a black line on a white surface, built on Arduino Uno with dual IR sensors and a motor driver shield.

E

Emeka Okafor

Emmanuel Anglican Secondary School

🤖

Built during the Robotics track, this was a collaborative project involving two students. The robot uses two infra-red sensors to detect the boundary between a black line and white surface, adjusting motor speed to stay on course.

Hardware used

  • Arduino Uno microcontroller
  • L298N dual H-bridge motor driver
  • 2× IR proximity sensors
  • 2× DC gear motors + chassis kit
  • 7.4V LiPo battery pack

How it works

Each sensor returns a HIGH signal when it detects white and LOW over black. A simple decision tree in the loop function steers the robot: both sensors on white = go straight, left sensor on black = turn left, right sensor on black = turn right.

void loop() {
  int leftVal  = digitalRead(LEFT_SENSOR);
  int rightVal = digitalRead(RIGHT_SENSOR);
  if (leftVal == HIGH && rightVal == HIGH) forward();
  else if (leftVal == LOW)  turnLeft();
  else if (rightVal == LOW) turnRight();
}

Share this project

Project Details

  • Category Robotics
  • Difficulty Intermediate
  • Student Emeka Okafor
  • School Emmanuel Anglican Secondary School

Browse By Category

Inspired by this project?

Your students can build projects just like this — with Techxagon Academy.