Line Following Robot Kit using Arduino Uno R3 Guide 2

Line following robot is an automated robot that can start on its own, decide its path and stop on its own. LFR follows a certain path controlled by a feedback mechanism. This is one of the most common projects made by students due to its ease in making and learning outcomes.

Line Follower Robot Components

  • Arduino Uno with cable: 1
  • IR Sensor:  2
  • L293D Module: 1
  • Jumper Wires: 20pcs
  • Chassis: 1
  • BO Motor: 2
  • Caster wheel: 1
  • Breadboard: 1
  • Wheels: 2
  • Screws set – 1
  • Clamps – 2
  • 9v Battery – 2
  • Battery Snap – 2

PROGRAM CODE:

 
/*------ Arduino Line Follower Code----- */ 
/*-------definning Inputs------*/ 
#define LS 2      // left sensor 
#define RS 3      // right sensor 
 
/*-------definning Outputs------*/ 
#define LM1 4       // left motor 
#define LM2 5       // left motor 
#define RM1 6       // right motor 
#define RM2 7       // right motor 
 
void setup () 
{ 
 pinMode(LS, INPUT);
pinMode(RS, INPUT);   
pinMode(LM1, OUTPUT);   
pinMode(LM2, OUTPUT);   
pinMode(RM1, OUTPUT);   
pinMode(RM2, OUTPUT); } 
 
void loop() 
{ 
  if(digitalRead(LS) && digitalRead(RS))     // Move Forward 
  { 
 digitalWrite(LM1, HIGH);     
digitalWrite(LM2, LOW);     
digitalWrite(RM1, HIGH);     
digitalWrite(RM2, LOW); 
  } 
   
  if(!(digitalRead(LS)) && digitalRead(RS))     // Turn right 
  { 
digitalWrite(LM1, LOW);     
digitalWrite(LM2, LOW);     
digitalWrite(RM1, HIGH);     
digitalWrite(RM2, LOW); 
  } 
   
  if(digitalRead(LS) && !(digitalRead(RS)))     // turn left 
  { 
digitalWrite(LM1, HIGH);     
digitalWrite(LM2, LOW);     
digitalWrite(RM1, LOW);     
digitalWrite(RM2, LOW); 
  } 
   
  if(!(digitalRead(LS)) && !(digitalRead(RS)))     // stop 
  { 
digitalWrite(LM1, LOW);     
digitalWrite(LM2, LOW);     
digitalWrite(RM1, LOW);     
digitalWrite(RM2, LOW); 
  } 
} 

2 Comments

  1. Do you have video on how to build this? I have purchased it

    1. Hello Narayanan,
      we have a video tutorial for a similar robot which have LDR sensor in place of IR sensor and it will resolve your purpose.
      Pls checkout this link : https://www.youtube.com/watch?v=tB_eLacGjbs&t=128s

      Thank you

Leave a Reply