Skip to main content

Line Follower Robot Using Arduino

                                         



Line follower Robot is a machine which follows a line, either a black line or white line. Basically there are two types of line follower robots: one is black line follower which follows black line and second is white line follower which follows white line. Line follower actually senses the line and run over it.


Concepts of Line Follower

Concept of working of line follower is related to light. We use here the behavior of light at black and white surface. When light fall on a white surface it is almost full reflected and in case of black surface light is completely absorbed. This behavior of light is used in building a line follower robot.

Concept of Black Line Follower Robot
In this arduino based line follower robot we have used IR Transmitters and IR receivers also called photo diodes. They are used for sending and receiving light. IR transmits infrared lights. When infrared rays falls on white surface, it’s reflected back and cached by photo diodes which generates some voltage changes and gives the output of value greater than 400. When IR light falls on a black surface, light is absorb by the black surface and no rays are reflected back, thus photo diode does not receive any light or rays and will give output value less than 400.

Image result for ir sensor arduino connections

Connections for IR sensor 1 :-


Arduino                                                                                         Ir sensor 1

Pin 6                                         Vcc
Gnd                                           Gnd
O/P                                            A0


Connections for IR sensor 2 :-


Arduino                                                                                         Ir sensor 2

Pin 7                                         Vcc
Gnd                                           Gnd
O/P                                            A1




Connections for Motor Driver :-



Here in L293d motor driver at the top we have total 7 pins . 4 Pins are used for controlling the motor and 3 pins in the middle of the l293d module are used for powering the module.

Connect the arduino and L293d as follows:-

Arduino Pins:-                L293d Motor Driver
Pin 13                                   M1 a                           // for controlling motor 1
Pin 12                                   M1 b
Pin 11                                   M2 a                           // for controlling motor 2
Pin 10                                   M2 b

Vin                                        12v
Gnd                                       Gnd                                     // providing power to L293d module
5v                                          5v


Working of Line Follower Robot using Arduino

Code for Line follower robot:-




void setup() {
  pinMode(13,OUTPUT);
  pinMode(12,OUTPUT);
  pinMode(11,OUTPUT);
  pinMode(10,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  digitalWrite(6,HIGH);
  digitalWrite(7,HIGH); 
}

void loop() {

  int sensorValue1 =analogRead(A0);
  int sensorValue2 =analogRead(A1);

  if(sensorValue1>400&&sensorValue2>400)
  {
    digitalWrite(13,HIGH);
    digitalWrite(12,LOW);
    digitalWrite(11,HIGH);
    digitalWrite(10,LOW);
    
  }
  else if(sensorValue1>400&&sensorValue2<400)
  {
    digitalWrite(13,HIGH);
    digitalWrite(12,HIGH);
    digitalWrite(11,HIGH);
    digitalWrite(10,LOW);
  }
  else if(sensorValue1<400&&sensorValue2>400)
  {
    digitalWrite(13,HIGH);
    digitalWrite(12,LOW);
    digitalWrite(11,HIGH);
    digitalWrite(10,HIGH);
  }
  
  // put your main code here, to run repeatedly:

}

Working:-


Condition 1 for forward move . both the motors will move clock wise direction so we have provided 

 if(sensorValue1>400&&sensorValue2>400)
  {
    digitalWrite(13,HIGH);
    digitalWrite(12,LOW);
    digitalWrite(11,HIGH);
    digitalWrite(10,LOW);
    
  }

as both the sensors will reflect light from the surface.
Working of Arduino Line Follower Robot
Condition 2 for right move . one of the motors (right side motor) will move clock wise direction and the other will be stopped(left side motor) so we have provided 

else if(sensorValue1>400&&sensorValue2<400)
  {
    digitalWrite(13,HIGH);
    digitalWrite(12,HIGH);
    digitalWrite(11,HIGH);
    digitalWrite(10,LOW);
  }

as both one of the the sensors will reflect light from the surface and other will not reflect light as it is on black line.
Turning left to line follower robot using arduino
Condition 3 for left move . one of the motors(left side motor) will move clock wise direction and the other will be stopped(right side motor) so we have provided 
 else if(sensorValue1<400&&sensorValue2>400)
  {
    digitalWrite(13,HIGH);
    digitalWrite(12,LOW);
    digitalWrite(11,HIGH);
    digitalWrite(10,HIGH);
  }



as both one of the the sensors will reflect light from the surface and other will not reflect light as it is on black line.
Turning right to line follower robot







Comments