Skip to main content

Arduino Line Following Car

Line Follower


    In this Arduino Tutorial I will Show you How to Make a Line Following Car Using Arduino Uno Board and Some Electronic Components . You can Watch this Video or Read the following blog for more details..


Working Principle :
        Line Follower has a basic and necessary Component  IR Sensor which act as Vision. It works on the principle of Black Surface Absorbs all  Wavelengths of Light Rays. Then the IR Sensors mounted infront of the car detects black line and makes a movement based on your code.

Components Required :

Construction :

  • First you need a cardboard of high Durability.
  • And Mount a Gear motors Using Double Sided Tape or GlueGun.
  • Place the Arduino Uno Board on the Cardboard Connected With L293D Motor Driver.
  • Connect the Gear motor Wires to the L293D Motor Driver.
  • And place the IR Senors infront of the Cardboard.
  • Connect Sensors to the Motor Driver Using Jumper Wires.
  • Make sure your Sensors Output Pins are Correctly Mounted with the Analog input Pins of Motor Driver.
  • Now move on to the Software Portion, Open Your Arduino IDE
  • Select line_following_car.ino file 
  • Download Required Libraries and Select Board & Port , Click Upload .
  • Now time to Connect a Battery. I use 2no's of li-ion 3.7V battery in Series Connection.
  • After Connecting Batteries, Switch on your Car and Place it on Track ,That will Follow the Black track line as follows.
  • That's Solve Guys !

Circuit Diagram :

            You can follow our DIY video For Circuit Diagram. I will clearly explained the connections of this Line following Car.

Arduino Code :

//CRATUS MK1
//LINE FOLLOWER WITH 4 MOTOR
//BY PRADEEP RAJ (M.P.R)
//FEBRUARY 29 2020
//          ------THIS CODE IS OPEN SOURCE FOR OUR SUBSCRIBERS------
//                         ------ THE FAUCETER ------


#include <AFMotor.h>


//defining pins and variables
#define left A1
#define right A0

//defining motors
AF_DCMotor motor1(1, MOTOR12_1KHZ); 
AF_DCMotor motor2(2, MOTOR12_1KHZ);
AF_DCMotor motor3(3, MOTOR34_1KHZ);
AF_DCMotor motor4(4, MOTOR34_1KHZ);



void setup() {
  //declaring pin types
  pinMode(left,INPUT);
  pinMode(right,INPUT);
  //begin serial communication
  Serial.begin(9600);
  
}

void loop(){
  //printing values of the sensors to the serial monitor
  Serial.println(digitalRead(left));
  
  Serial.println(digitalRead(right));

  //line detected by both
  if(digitalRead(left)==0 && digitalRead(right)==0){
    //Forward
    motor1.run(FORWARD);
    motor1.setSpeed(120);   //full speed for motor is 255
    motor2.run(FORWARD);
    motor2.setSpeed(120);
    motor3.run(FORWARD);
    motor3.setSpeed(120);
    motor4.run(FORWARD);
    motor4.setSpeed(120);
  }
  //line detected by left sensor
  else if(digitalRead(left)==0 && !analogRead(right)==0){
    //turn left
    motor1.run(BACKWARD);
    motor1.setSpeed(200);
    motor2.run(FORWARD);
    motor2.setSpeed(200);
    motor3.run(FORWARD);
    motor3.setSpeed(200);
    motor4.run(BACKWARD);
    motor4.setSpeed(200);
    
  }
  //line detected by right sensor
  else if(!digitalRead(left)==0 && digitalRead(right)==0){
    //turn right
    motor1.run(FORWARD);
    motor1.setSpeed(200);
    motor2.run(BACKWARD);
    motor2.setSpeed(200);
    motor3.run(BACKWARD);
    motor3.setSpeed(200);
    motor4.run(FORWARD);
    motor4.setSpeed(200);
   
  }
  //line detected by none
  else if(!digitalRead(left)==0 && !digitalRead(right)==0){
    //stop
    motor1.run(RELEASE);
    motor1.setSpeed(0);
    motor2.run(RELEASE);
    motor2.setSpeed(0);
    motor3.run(RELEASE);
    motor3.setSpeed(0);
    motor4.run(RELEASE);
    motor4.setSpeed(0);
   
  }
  
}

//-----------------------------------THE FAUCETER---------------------------------------

Click Here to Download

Comments

Post a Comment

Popular posts from this blog

Arduino Smart Car

Smart Car          In this Arduino Tutorial I will show You How to make a Smart Car using Arduino Uno Board and other some Electronic Components. You can Watch this Video or Read the Following Blog for more details.

Measuring Distance Using UltraSonic Sensor with Arduino

Measuring Distance     Using Arduino, UltraSonic Sensor & OLED Display                In this Arduino Tutorial , I will show you How to Measure a Distance of an Object Using Arduino , UltraSonic Sensor & OLED Display . You can watch this Video or Read the following Blogs for More Details.

NodeMCU WiFi Car

 WiFi Car    In this Tutorial I will Show you How to Make a WiFi Car Using NodeMCU ESP8266 Board and Some Electronic Components . You can Watch this Video or Read the following blog for more details..

N95 Respirator Mask

N95

Arduino Object Following Robot

Object Following Robot     Watch the entire DIY Video of making (J.A.O.F) Arduino Object Following Robot...

NodeMCU WiFi Switch

 Wi-Fi Switch          In this Tutorial , I will Show you How to Control your Home Appliances by Using Smartphone Over WiFi Connection with NodeMCU ESP8266 Board and Relay(Electric Switch). You can watch this Video or read the following Blog for more Details...