Project tutorial
Easiest Line Follower Robot

Easiest Line Follower Robot © CC BY

Its super simple, low cost (2 sensor based) line follower robot. If you are a absolute beginner, you can make it only in 2 hours.

  • 29,383 views
  • 13 comments
  • 47 respects

Components and supplies

Necessary tools and machines

Hy gluegun
Hot glue gun (generic)
Screw Driver
line following Robotic kit

Apps and online services

About this project

Line follower robot is hello world to robotics arena. This line follower is very simple, easy to build robot.

Code

Arduino Based Line follower Robot C/C++
/*-------definning Inputs------*/
#define LS  2    // left sensor
#define RS  5    // right sensor


/*-------definning Outputs------*/
#define LM1 11    // left motor
#define LM2 10    // left motor
#define RM1 9    // right motor
#define RM2 6     // 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)==LOW) && (digitalRead(RS)==LOW))    // Condition_1 stop
{    
    MoveForward();
  }
  
  if((digitalRead(LS)==HIGH) && (digitalRead(RS)==HIGH))  //CONDITION-2 FORWRD
  {
      Stop();
    }
  if((digitalRead(LS)==LOW) && (digitalRead(RS)==HIGH))  // RIGHT
  {
    TurnLeft();
  }
  if((digitalRead(LS)==HIGH) && (digitalRead(RS)==LOW))
  {
    TurnRight();
  }
}



void MoveForward()
{
    analogWrite(LM1, 50);
    analogWrite(LM2, 0);
    analogWrite(RM1, 50);
    analogWrite(RM2, 0);
    delay(20);
}

void TurnRight()
{
    analogWrite(LM1, 0);
    analogWrite(LM2, 60);
    analogWrite(RM1, 60);
    analogWrite(RM2, 0);
    delay(30); 
}

void TurnLeft()
{
    analogWrite(LM1, 60);
    analogWrite(LM2, 0);
    analogWrite(RM1, 0);  
    analogWrite(RM2, 60);
    delay(30);
}

void Stop()
{
    analogWrite(LM1, 0);
    analogWrite(LM2, 0);
    analogWrite(RM1, 0);
    analogWrite(RM2, 0);
    delay(20);
}

Schematics

Circuit Block Diagram
2017 05 10 13 43 03 jd7qakz9tr

Comments

Similar projects you might like

Elliot the Line Follower Robot

Project showcase by SMM2

  • 10,250 views
  • 5 comments
  • 25 respects

Make your first Arduino robot - The best beginners guide!

Project tutorial by Muhammed Azhar

  • 65,303 views
  • 19 comments
  • 148 respects

PID Control Line Follower Robot

Project tutorial by Team KittenBot

  • 24,026 views
  • 5 comments
  • 36 respects

Smartphone Controlled Arduino 4WD Robot Car

Project in progress by Andriy Baranov

  • 80,522 views
  • 54 comments
  • 153 respects

Line Follower Robot - PID Control - Android Setup

Project tutorial by MJRoBot

  • 34,800 views
  • 10 comments
  • 45 respects

MeArm Robot Arm - Your Robot - V1.0

Project tutorial by Benjamin Gray

  • 27,519 views
  • 4 comments
  • 41 respects
Add projectSign up / Login