Project tutorial
Line Follower Robot

Line Follower Robot © CC BY-SA

Learn how to make a simple line follower robot by using Arduino and very basic electronic components. It is a fully autonomous robot.

  • 4,622 views
  • 3 comments
  • 14 respects

Components and supplies

Apps and online services

About this project

Let's make a fully autonomous robot using Arduino and IR sensors. It can follow a black line on white surface. Watch video for more!

Components used:

  • Piece of cardboard/ Acrylic sheet
  • Arduino Uno
  • IR sensor
  • BO motor
  • Wheels
  • Caster wheel
  • L293d IC
  • PCB
  • Flexible wire
  • Battery

Fix all components on acrylic sheet and make a chassis as shown in pictures.

Now make all connection As per the circuit Diagram bellow.

you can make this circuit on dotted pcb like this.

or can use this type of professional looking PCB.

you can order PCB for this Shield from here https://www.pcbway.com/project/shareproject/How_to_Make_Arduino_Based_Edge_Avoiding_Robot.html

or for ready made shield contact us on: https://www.facebook.com/STROniXTechnologies

Now it's time to program this robot. upload this program to arduino and all done.

 //program by Shubham Shinganapure on 05-08-2019
//
//for Line Following Robot using 2IR sensors  
int lm1=8; //left motor output 1
int lm2=9; //left motor output 2
int rm1=10;  //right motor output 1
int rm2=11;  //right motor output 2
int sl=13;    //sensor 1 input (left)
int sr=12;    //sensor 2 input (right)
int SlV=0;
int SrV=0;
int led=A0;
void setup()
{
 pinMode(lm1,OUTPUT);
 pinMode(lm2,OUTPUT);
 pinMode(rm1,OUTPUT);
 pinMode(rm2,OUTPUT);
 pinMode(led,OUTPUT);
 pinMode(sl,INPUT);
 pinMode(sr,INPUT);
sTOP();
}
void loop()
{
 SlV=digitalRead(sl);
 SrV=digitalRead(sr);
 if(SrV==LOW && SlV== LOW)
 {
  ForWard();
   }
 if(SrV==HIGH && SlV== LOW)
 {
  Left();
   }
 if(SrV==LOW && SlV== HIGH)
 { 
 Right();
  }
    if(SrV==HIGH && SlV== HIGH)
 {
  sTOP();
   }
}
void ForWard()
 {
  digitalWrite(lm1,HIGH);
  digitalWrite(lm2,LOW);
  digitalWrite(rm1,HIGH);
  digitalWrite(rm2,LOW);
 } 
 void BackWard()
 {
  digitalWrite(lm1,LOW);
  digitalWrite(lm2,HIGH);
  digitalWrite(rm1,LOW);
  digitalWrite(rm2,HIGH);
 }
 void Left()
 {
  digitalWrite(lm1,LOW);
  digitalWrite(lm2,HIGH);
  digitalWrite(rm1,HIGH);
  digitalWrite(rm2,LOW);
 } 
 void Right()
 {
  digitalWrite(lm1,HIGH);
  digitalWrite(lm2,LOW);
  digitalWrite(rm1,LOW);
  digitalWrite(rm2,HIGH);
 }  
   void sTOP()
 {
  digitalWrite(lm1,LOW);
  digitalWrite(lm2,LOW);
  digitalWrite(rm1,LOW);
  digitalWrite(rm2,LOW);
 }  
  

For more subscribe my youtube channel: https://www.youtube.com/c/shubhamshinganapure

Code

line follower robotArduino
//program by Shubham Shinganapure on 05-08-2019
//
//for Line Following Robot using 2IR sensors  
int lm1=8; //left motor output 1
int lm2=9; //left motor output 2
int rm1=10;  //right motor output 1
int rm2=11;  //right motor output 2
int sl=13;    //sensor 1 input (left)
int sr=12;    //sensor 2 input (right)
int SlV=0;
int SrV=0;
int led=A0;
void setup()
{
 pinMode(lm1,OUTPUT);
 pinMode(lm2,OUTPUT);
 pinMode(rm1,OUTPUT);
 pinMode(rm2,OUTPUT);
 pinMode(led,OUTPUT);
 pinMode(sl,INPUT);
 pinMode(sr,INPUT);
sTOP();
}
void loop()
{
 SlV=digitalRead(sl);
 SrV=digitalRead(sr);
 if(SrV==LOW && SlV== LOW)
 {
  ForWard();
   }
 if(SrV==HIGH && SlV== LOW)
 {
  Left();
   }
 if(SrV==LOW && SlV== HIGH)
 { 
 Right();
  }
    if(SrV==HIGH && SlV== HIGH)
 {
  sTOP();
   }
}
void ForWard()
 {
  digitalWrite(lm1,HIGH);
  digitalWrite(lm2,LOW);
  digitalWrite(rm1,HIGH);
  digitalWrite(rm2,LOW);
 } 
 void BackWard()
 {
  digitalWrite(lm1,LOW);
  digitalWrite(lm2,HIGH);
  digitalWrite(rm1,LOW);
  digitalWrite(rm2,HIGH);
 }
 void Left()
 {
  digitalWrite(lm1,LOW);
  digitalWrite(lm2,HIGH);
  digitalWrite(rm1,HIGH);
  digitalWrite(rm2,LOW);
 } 
 void Right()
 {
  digitalWrite(lm1,HIGH);
  digitalWrite(lm2,LOW);
  digitalWrite(rm1,LOW);
  digitalWrite(rm2,HIGH);
 }  
   void sTOP()
 {
  digitalWrite(lm1,LOW);
  digitalWrite(lm2,LOW);
  digitalWrite(rm1,LOW);
  digitalWrite(rm2,LOW);
 } 

Schematics

line follower robot ckt
Uploads2ftmp2fccc8aa0a a93f 4620 a613 1b79cb4980a02f0001sav28229 nlq7xiynka

Comments

Similar projects you might like

Make an Arduino-Based Edge Avoiding Robot

Project tutorial by Shubham Shinganapure

  • 2,690 views
  • 0 comments
  • 15 respects

Amazing 6WD Off-Road Robot | Arduino RC Robot

Project tutorial by Jithin Sanal

  • 7,816 views
  • 0 comments
  • 50 respects

Simple Line Follower Robot

Project tutorial by WolfxPac

  • 3,418 views
  • 0 comments
  • 10 respects

PID Control Line Follower Robot

Project tutorial by Team KittenBot

  • 24,026 views
  • 5 comments
  • 36 respects

Easiest Line Follower Robot

Project tutorial by Zubayer Al Billal Khan

  • 29,175 views
  • 13 comments
  • 47 respects

Line Follower Robot (PICTO 92)

Project tutorial by MEGA DAS

  • 3,526 views
  • 0 comments
  • 8 respects
Add projectSign up / Login