How To Make Line Follower Robot Using Arduino

When we talk about simple robotics technology that is operated through any kind of microcontroller, then a popular name is come out i.e a Line Follower Robot. Line follower robot is a self automation robotic technology that can detect a visual line on the floor. This is the line in which the robot can follow this and it should be a black line on a white surface (vice versa can be possible). At a certain advanced level, an upgraded line follower robot can follow a magnetic field as the following path.

Large line follower robots are used due to the automated production process in industries. It not only used in industries but also in military applications, human assistance purposes, and also in delivery services, etc.

The line follower robot is the best robotics project in which a beginner level school and engineering students can easily build this. In this project, we will be going to build a simple Arduino based line follower robot with few components.

Circuit Diagram

line follower robot circuit

Components Required

  • Arduino
  • L298 Motor Driver
  • Geared Motors
  • IR Sensor Module
  • Black Tape (Electrical Tape)
  • Connecting Wires
  • Robot Chassis
  • 9V Power supply
  • Battery Connector

Note: Here we are using a ready-made IR Sensor module, but you can use your own IR Sensor module. Here is the link to “How to build an IR Sensor module

About Parts

Microcontroller

The microcontroller that I have used here is Arduino Nano because it is simple to use. You can also use an Arduino UNO or Arduino mini but I would recommend you stick with NANO since it is small than a UNO, so it can easily fit in a small chassis.

line follower robot microcontroller

L298 Motor Driver

If you have selected the DC geared motors then you can either use the L298N driver module or an L293D driver module. Both are similar in work. The Difference is that L298N is more powerful than L293D. But in that case, we can use any of them.

line follower robot motor driver

Motor

The best choice of motor that you can use for a line following robot, without a doubt will be a DC geared motor. Yes, it is not mandatory to have a costly motor; the bot works fine with these cheap yellow-colored DC geared motors as well.

robot motor

Wheel

I had a tough time figuring out that the problem was with my wheels. So make sure your wheels have a good grip over the floor you are using. Watch closely, your grip should never allow your wheels to skit on the floor.

robot wheel

Chassis

Another place where you should not compromise is with your robot’s chassis. You can use cardboard, wood, plastic anything that you are good with the line following robot. But, just make sure the chassis is sturdy and should not wiggle when the robot is trying to run. I have designed my own chassis with cardboard.

Note: The power supply to the motors must be given from the motor driver IC. Hence, choose the appropriate power supply which is sufficient for all the components including the motors.

Working of Arduino Line Follower Robot

In this project, we have built an Arduino based Line Follower Robot. The working principle of this line follower robot is too easy. It detects the black line on the surface and goes through that line. We explained a detailed description of this project.

As mentioned in the above circuit diagram, we need sensors to detect the line. For line detection logic, we used two IR Sensor modules, which consist of an IR Transmitter and an IR Receiver. So that whenever they come into proximity of a reflective surface, the light emitted by the IR Transmitter will be detected by the IR receiver.

As the reflectance of the light-colored surface is high, the infrared light emitted by the IR Transmitter will be maximumly reflected and will be detected by the IR Receiver.

In the case of the black surface, which has a low reflectance, the black surface completely absorbs the IR rays and doesn’t reach the IR Receiver.

Using the same principle, we will setup the IR Sensors on the line follower robot such that the two IR Sensors are on the either side of the black line on the floor.

When the robot moves forward, both the sensors wait for the line to be detected. For example, if the IR Sensor 1 detects the black line, it means that there is a right curve (or turn) ahead.

Arduino detects this change and sends signal to motor driver accordingly. In order to turn right, the motor on the right side of the robot is slowed down using PWM, while the motor on the left side is run at normal speed.

Similarly, when the IR Sensor 2 detects the black line first, it means that there is a left curve ahead and the robot has to turn left. For the robot to turn left, the motor on the left side of the robot is slowed down (or can be stopped completely or can be rotated in opposite direction) and the motor on the right side is run at normal speed.

Arduino continuously monitors the data from both the sensors and turns the robot as per the line detected by them.

Application of Line Follower Robot

Line follower Robots are in use for the automation processes in industries, military applications, etc.

They are very useful as they can work without any supervision i.e. they work as automatic guided vehicles.

With additional features like obstacle avoidance and other security measures, line follower robots can be used in driver less cars.

Arduino Code

//Electro Gadget - circuitdiagrams.in

int mot1=9;
int mot2=6;
int mot3=5;
int mot4=3;

int left=13;
int right=12;
int Left=0;
int Right=0;

void LEFT (void);
void RIGHT (void);
void STOP (void);

void setup()
{
  pinMode(mot1,OUTPUT);
  pinMode(mot2,OUTPUT);
  pinMode(mot3,OUTPUT);
  pinMode(mot4,OUTPUT);

  pinMode(left,INPUT);
  pinMode(right,INPUT);

  digitalWrite(left,HIGH);
  digitalWrite(right,HIGH);
  
}

void loop() 
{
 
analogWrite(mot1,255);
analogWrite(mot2,0);
analogWrite(mot3,255);
analogWrite(mot4,0);

while(1)
{
  Left=digitalRead(left);
  Right=digitalRead(right);
  
  if((Left==0 && Right==1)==1)
  LEFT();
  else if((Right==0 && Left==1)==1)
  RIGHT();
}
}

void LEFT (void)
{
   analogWrite(mot3,0);
   analogWrite(mot4,30);
   
   while(Left==0)
   {
    Left=digitalRead(left);
    Right=digitalRead(right);
    if(Right==0)
    {
      int lprev=Left;
      int rprev=Right;
      STOP();
      while(((lprev==Left)&&(rprev==Right))==1)
      {
         Left=digitalRead(left);
         Right=digitalRead(right);
      }
    }
    analogWrite(mot1,255);
    analogWrite(mot2,0); 
   }
   analogWrite(mot3,255);
   analogWrite(mot4,0);
}

void RIGHT (void)
{
   analogWrite(mot1,0);
   analogWrite(mot2,30);

   while(Right==0)
   {
    Left=digitalRead(left);
    Right=digitalRead(right);
    if(Left==0)
    {
      int lprev=Left;
      int rprev=Right;
     STOP();
      while(((lprev==Left)&&(rprev==Right))==1)
      {
         Left=digitalRead(left);
         Right=digitalRead(right);
      }
    }
    analogWrite(mot3,255);
    analogWrite(mot4,0);
    }
   analogWrite(mot1,255);
   analogWrite(mot2,0);
}
void STOP (void)
{
analogWrite(mot1,0);
analogWrite(mot2,0);
analogWrite(mot3,0);
analogWrite(mot4,0);
}

Leave a comment