ATmega8 Line Follower Robot (LFR) Project – Part 1/2

Robotics is the branch of technology that deals with the design, construction, operation, and application of robots, as well as computer systems for their control, sensory feedback, and information processing. The word robotics comes from Runaround, a short story published in 1942 by Isaac Asimov. Robot is an electro-mechanical machine that is guided by a computer program or electronic circuitry.

A robot system contains sensors, control systems, manipulators, power supplies and software all working together to perform an assigned task. One of the most basic autonomous robot you can build is a line following robot(LFR). The purpose of this AVR tutorial-part 23 is to help you build a Line Following Robot using an inexpensive AVR chip, that can follow an arbitrary path!


Our LFR is fairly a good line follower robot, consists of low-priced electro-mechanical parts, electronic components, and a microcontroller chip-based processor circuitry. Bare essentials are listed below:

  • Robot Chassis
  • Robot Motors
  • Caster Bullets
  • Robot Wheels
  • IR Sensor Cards
  • IC L293D
  • IC Atmega8
  • Motor Clamps, Switches,B attery Holders, Batteries, Small Electronic Components, Screws & Nuts, etc.

The line follower logic can be divided into two (sensing and controlling) segments. At first, LFR logic observes the track pattern ahead. In the second phase, the logic operates two drive motors (left and right) as per the informed track status. The infrared sensor card contains infrared light emitting diodes and infrared photodiodes.

The dual-channel motor controller is a simple H-Bridge driver chip L293D. Brain of the line follower robot is one Atmega8 microcontroller.


LFR-Mechanical Assembly

First of all attach motors, clamps and wheels as illustrated here. Next, attach two caster bullets (front and rear) at the bottom of the chassis. Finally, drill suitable holes in the chassis to fit all remaining parts such as finished circuit board, sensor cards, battery holder, pcb spacers, supporting clamps, etc.


The battery holder can be fitted at the rear-top of the chassis, just near the caster bullet. Best location for main circuit board is the centre-top of the chassis. The infrared sensor cards (left and right) should be fitted at the front-side of the chassis, in downward direction, so that infrared sensor components (light sender and receiver) can comfortably catch the underneath path.


Take a note, our LFR follows a path with black track on white surface. To sense the track properly, infrared sensors must be placed on the chassis in such a way that they are very close to the track level. Ensure that distance between two infrared sensor card (left and right) must be 3 to 6mm greater than the width of the marking on the track.


LFR-System Logic

As described earlier, our LFR is a simple robot which will follow a black line on a white background. This AVR chip-based LFR has a very simple logic, discussed below using if-else in the pseudo code.

IF (Left side of the LFR is about to touch the left side of the track)
Turn Right;
ELSE IF (Right side of the LFR is about to touch the right side of the track)
Turns Left;
Move Forward;

If both infrared sensors (left and right) are on the white surface, the LFR will move forward, and if both sensors are on black surface, the LFR will stop. When the left sensor is on white and right sensor is on black, LFR will take a right-turn. Similarly, when the right sensor is on white and left sensor is on black, LFR will take a left-turn. These four cases are the only possible conditions for a basic line follower robot.

LFR-IR Sensor Card Circuit diagram

Our LFR has two infrared sensor cards (left and right) on the bottom of the chassis for detecting the black tracking indicant on the path. Each sensor card is a combination of an infrared LED, infrared photodiode, and a comparator chip works on 5V DC supply. The comparator circuit is wired using one-part (½) of the LM358 IC.


In the default jumper condition (JP:1+2), output of the infrared sensor card is at a logic-low (L) state, when it detects a black color, and vice versa. Remember, we need two identical infrared sensor cards; one for left side, and other one for right side!

→ Part 24: ATmega8 Line Follower Robot (LFR) Project – Part 2/2
← Part 22: Bootload an ATmega Microcontroller & Build Your Own Arduino – 2