Simple Line Follower

Simple Line Follower

Arduino using IR sensor for basic line follower.

  • 1,085 views
  • 0 comments
  • 6 respects

Components and supplies

Ph a000066 iso (1) ztbmubhmho
Arduino UNO
×1
L239d motor driver
×1
11769 06
SparkFun RedBot Sensor - Line Follower
×2
DC motor (generic)
×2
Tens70
9V battery (generic)
×1
Chassis
×1

Apps and online services

About this project

This robot was made to take part in Fall Indoor Competition organized by DPRG 2018 and won the second prize:

https://www.dprg.org/fall-indoor-competition-results/



Code

Basic Line followerC/C++
/*Author: Ajaya Dahal
 * created on: 08/20/2018
*/


/*-------definning Inputs------*/
#define leftSensor 2      // left sensor
#define rightSensor 3      // right sensor

/*-------definning Outputs------*/
#define leftMotor 4       // left motor
#define leftMotor2 5       // left motor
#define rightMotor1 6       // right motor
#define rightMotor2 7       // right motor

void setup()
{
  pinMode(leftSensor, INPUT);
  pinMode(rightSensor, INPUT);
  pinMode(leftMotor, OUTPUT);
  pinMode(leftMotor2, OUTPUT);
  pinMode(rightMotor1, OUTPUT);
  pinMode(rightMotor2, OUTPUT);
}

void loop()
{
  if(digitalRead(leftSensor) && digitalRead(rightSensor))     // Move Forward
  {
    digitalWrite(leftMotor, HIGH);
    digitalWrite(leftMotor2, LOW);
    digitalWrite(rightMotor1, HIGH);
    digitalWrite(rightMotor2, LOW);
  }
  
  if(!(digitalRead(leftSensor)) && digitalRead(rightSensor))     // Turn right
  {
    digitalWrite(leftMotor, LOW);
    digitalWrite(leftMotor2, LOW);
    digitalWrite(rightMotor1, HIGH);
    digitalWrite(rightMotor2, LOW);
  }
  
  if(digitalRead(leftSensor) && !(digitalRead(rightSensor)))     // turn left
  {
    digitalWrite(leftMotor, HIGH);
    digitalWrite(leftMotor2, LOW);
    digitalWrite(rightMotor1, LOW);
    digitalWrite(rightMotor2, LOW);
  }
  
  if(!(digitalRead(leftSensor)) && !(digitalRead(rightSensor)))     // stop
  {
    digitalWrite(leftMotor, LOW);
    digitalWrite(leftMotor2, LOW);
    digitalWrite(rightMotor1, LOW);
    digitalWrite(rightMotor2, LOW);
  }
}

Schematics

uploads2ftmp2f38282880-0e70-4332-8352-9176a1f747f02fyoucut_20190923_2056052735b15d_2GEwThbyjw.mp4
Schematics
Uploads2ftmp2f46b8a26e 23ca 43fb bcbd 4e23cae78f2a2fschematics fhmk2dajaw

Comments

Similar projects you might like

Simple Line Follower Robot

Project tutorial by Harsh Dethe

  • 8,127 views
  • 0 comments
  • 12 respects

A Simple Light Follower

Project tutorial by a_guadalupi

  • 10,364 views
  • 2 comments
  • 11 respects

Line Follower Robot

Project tutorial by Shubham Shinganapure

  • 20,400 views
  • 4 comments
  • 32 respects

Elliot the Line Follower Robot

Project showcase by SMM2

  • 15,972 views
  • 6 comments
  • 28 respects

Line Follower Robot

Project tutorial by Saher Iqbal

  • 16,355 views
  • 4 comments
  • 4 respects

Simple Gesture Controlled Robot Using Arduino

Project tutorial by Jithin Sanal

  • 15,345 views
  • 2 comments
  • 36 respects
Add projectSign up / Login