Sunday, April 26, 2020

Home >> Arduino Projects >> How to make Line Follower Robot using Arduino

How to make Line Follower Robot using Arduino


How to make Arduino Line Follower Robot


A line follower robot, as the name suggests, is an automated guided vehicle, which follows a visual line embedded on the floor or ceiling. Typically, the visual line is the path in which the line follower robot goes and it will be a black line on a white surface but another path (a white line on a black surface) is also possible. Some advanced line follower robots use invisible magnetic fields as their paths.

Large line follower robots are commonly used in industries to aid the automated production process. They are also used in military applications, human support purposes, delivery services, etc.

The line follower robot is the first robot to get its first robotic experience with beginners and students. In this project, we have designed a simple line follower robot using Arduino and some other components.
Arduino LFR (Line Follower Robot) कैसे बनाएं?
Line Follower Robot 1

Arduino LFR (Line Follower Robot) कैसे बनाएं?
Line Follower Robot 2

Arduino LFR (Line Follower Robot) कैसे बनाएं?
Line Follower Robot 3

Arduino LFR (Line Follower Robot) कैसे बनाएं?
Line Follower Robot 4

How to make Arduino LFR (Line Follower Robot) : Essential components

   1. Arduino UNO (or Arduino Nano) [Buy Here]

    2.L293D Motor Driver IC [Buy Here]

    3. Gear x 2

    4. Robot Chassis

    5. IR sensor module x 2

    6. Black tape (electrical insulation tape)

    7. Connecting the wires

    8. Power Supply

    9. Battery Connector

    10.Battery

How to make Arduino Line Follower Robot : circuit diagram



Arduino Line Follower Robot Circuit
Note: We have used a prefabricated IR sensor module consisting of an IR LED and a photo diode. If you do not have it, we have explained how to make yourself.

Project block diagram

The line follower robot manufactured in this project is divided into 4 blocks. The following image depicts the block diagram for the line follower robot.


Arduino LFR (Line Follower Robot) कैसे बनाएं?
Block diagram description
Sensor (IR sensor): We have used the IR sensor module as a sensor detection line for the project. It consists of an IR LED and a photo diode and some other components like comparator, LED etc.


IR sensor module

As mentioned earlier, we have used the pre-assembled IR sensor. If you do not have one, you can make your own sensor using the following circuit.

Arduino LFR (Line Follower Robot) कैसे बनाएं?

 IR Sencer


How to make Arduino Line Follower Robot : IR sensor circuit



Arduino LFR (Line Follower Robot) कैसे बनाएं?

IR Sencer Circuit


In this project the function of IR sensor and its scope will be explained in the actual work of line follower robot.

Controller (Arduino UNO): Arduino UNO is the main controller in the project. The data from the sensor (IR sensor) will be passed to the Arduino and it gives the corresponding signal to the motor driver IC.

Motor Driver (L293D): L293D Motor Driver IC is used in this project to drive robot motors. It receives signals from the Arduino based on the information from the IR sensor.


Note: The power supply to the motors must be supplied from the motor driver IC. Therefore, select the appropriate power supply that is sufficient for all components, including motors.



Motors (geared motor): We have used two geared motors behind the line follower robot. These motors provide more torque than normal motors and can also be used to lift some loads.


 How to make Arduino Line Follower Robot: Working of Arduino Line Follower Robot

In this project, we have designed an Arduino based line follower robot. The project work is very simple: find the black line on the surface and move along that line. Detailed work is explained here.

As mentioned in the block diagram, we need a sensor to detect the line. For line detection logic, we used two IR sensors, which include IR LED and Photodiode. They are placed in a reflective manner i.e. side-by-side so that whenever they come in proximity to a reflective surface, the light emitted by the IR LED can be detected by the photo diode.

The following image shows the work of a specific IR sensor (IR LED - photodiode pair) in front of a light colored surface and a black surface. Since the reflectance of the light colored surface is high, the infrared light emitted by the IR LED will be reflected maximum and detected by the photodiode.

How to make Arduino Line Follower Robot
Arduino LFR (Line Follower Robot) कैसे बनाएं?

IR sensor working

IR sensor working


In the case of black surface, which has low reflectance, light is completely absorbed by the black surface and does not reach the photodiode.

Using the same principle, we will setup the IR sensor on a line follower robot, such that two IR sensors are on either side of the black line on the floor. The setup is shown below.
Arduino LFR (Line Follower Robot) कैसे बनाएं?

In the IR follower line follower when the robot moves forward, both sensors wait for the line to be detected. For example, if the IR sensor in the above image detects 1 black line, it means that there is a forward right curve (or bend).

The Arduino UNO detects this change and sends the signal to the motorist accordingly. To turn right, the motor on the right of the robot is slowed down using PWM, while the motor on the left is driven at normal speed.

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

The Arduino UNO continuously monitors data from both sensors and turns on the robot according to the line they searched.


How to make Arduino Line Follower Robot:  CODE

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);
  
}

  Note:

  • To increase the efficiency of black line detection, the number of sensors can be increased. An array of sensors would be more accurate than just two sensors. 
  • In this project (where two sensors are used), the position of the sensor is very important. The width of the black line plays a major role in the placement of the sensor.
  • Sensors can also be constructed for line detection using an LED and LDR pair.


Line follower robot applications

  •     Line follower robots are commonly used for automation processes in industries, military applications, and consumer applications.
  •     They are very useful as they can operate without any supervision i.e. they operate as automatic guided vehicles.
  •     Line follower robots can be used in driverless cars, with additional features such as obstacle avoidance and other safety measures.