Skip to main content

Line Follower Robot

Line Follower Robot Using Arduino

If you're getting started with robotics one among the primary project that beginners make includes a line follower. it's a special toy car with property to line a line which normally is black in color and in contrast with background. Let's start .


We can divide line follower in four major blocks IR photo diode sensor, motor driver, Arduino nano/code and toy car chassis which is formed from acrylic sheet, plastic wheels and 6V DC motors.   

 
Components Used:
  • IR Photodiode Sensor
  • Arduino
  • LM741 op-amp
  • Resistor
  • L293D Motor Driver
  • Motors
  • Connecting Wires
  • Chassis Of Toy Car
Let's check out these blocks one by one. Job of IR-photodiode sensor in line follower is to detect if it's a black line underneath it IR light emitted from IR LED bounces back from surface underneath to be captured by photodiode. Current through photo diode is proportional to photons it receives and physics says that black color absorbs IR radiation. Hence if we've black line under a photodiode it receives less photons leading to lesser current, compared to if it had reflective color like white underneath it. we'll use this circuit to convert photodiode's current signal into digital voltage signal the arduino can read using digital Read command. On breadboard is poor replica of this circuit. Photodiode's current is skilled a ten KOhm resistor to make proportional drop , let's call it Vphoto. If there's white surface underneath, photodiode's current goes up and hence Vphoto. On the opposite hand for block surface both decreases. Vphoto is connected to Non-inverting terminal of LM741 opamp. during this configuration, if voltage at Non-Inverting terminal is bigger than voltage at Inverting terminal. Opamp's output is about to high and low for other way round. We carefully set voltage at Inverting pinto be in-between voltage reading for white and black colors employing a potentiometer. On doing so this circuit's output is high for white and low for black color. Which is ideal for arduino to read up. just one IR-photodiode sensor isn't enough for creating a line follower because if we had just one IR-photodiode sensor we cannot know the direction of exit of follower to catch up on using motors. Hence, I bought this sensor module containing 6 IR-photodiode sensors, 3 clusters during a set of two .

Principle Of working:
If center cluster reads black and other two read white we will keep going forward. If left cluster reads black we'd like to show follower towards left to stay it on target and same applies for right cluster. to maneuver follower i'm using 2 6V DC motors,which are controlled using L293D motor driver. If motor is connected as shown on left. Setting enable and 1A pin to HIGH along side 2A pin to LOW, moves motor in one direction. to maneuver it in other direction we'd like to exchange the state of 2A and 1A pins. we do not need bidirectional movement as follower always move forward. to show left we disable left motor while motor on right is kept running and vice-versa. 5V arduino nano running at 16 MHz decides whether follower must turn left or right. Decisions are made by watching IR photodiode sensor array readings. Let's check out arduino code which is pretty simple . Initially we declare 6 sensor and 4 motor pins. In setup we set motor pins to output as default mode is input. In Loop, first we read all sensor pins, following that's a sequence of If-else statements that decide the movement of follower. Some statements let follower to maneuver forward. Some stops it and a few allows it to travel either left or right. Finally everything was put together consistent with this schematic provided above.

Code:

//sensor pins

const int IR0 = 2;

const int IR1 = 3;

const int IR2 = 4;

const int IR3 = 5;

const int IR4 = 6;

const int IR5 = 7;

//Motor control pins-

//left motor- MOT0 & MOT1

//right motor- MOT2 & MOT3

const int MOT0 = 9;

const int MOT1 = 8;

const int MOT2 = 10;

const int MOT3 = 11;

void setup() {

      pinMode(MOT0,OUTPUT);

      pinMode(MOT1,OUTPUT);

      pinMode(MOT2,OUTPUT);

      pinMode(MOT3,OUTPUT);

      // initialize the serial communications:

      //Serial.begin(115200);

}

void loop() {

      int S0 = digitalRead(IR0);

      int S1 = digitalRead(IR1);

      int S2 = digitalRead(IR2);

      int S3 = digitalRead(IR3);

      int S4 = digitalRead(IR4);

      int S5 = digitalRead(IR5);

      // print the sensor values:

      //Conditions to drive line folower appropriately

      if (S0==0 && S1==0 && S2==0 && S3==0 && S4==0 && S5==0) {

            //stop

            digitalWrite(MOT0,LOW);

            digitalWrite(MOT1,LOW);

            digitalWrite(MOT2,LOW);

            digitalWrite(MOT3,LOW);

      } else if (S0==1 && S1==1 && S2==1 && S3==1 && S4==1 && S5==1) {

            //stop

            digitalWrite(MOT0,LOW);

            digitalWrite(MOT1,LOW);

            digitalWrite(MOT2,LOW);

            digitalWrite(MOT3,LOW);

      } else if (S2==0 && S3==0) {

            //if two sensors at the middle reads 0, go straight

            digitalWrite(MOT0,HIGH);

            digitalWrite(MOT1,LOW);

            digitalWrite(MOT2,LOW);

            digitalWrite(MOT3,HIGH); 

      } else if (S1==0 && S2==0) {

            //follower moving towads right, stop left motor

            //digitalWrite(MOT0,LOW);

            analogWrite(MOT0, 125);

            digitalWrite(MOT1,LOW);

            digitalWrite(MOT2,LOW);

            digitalWrite(MOT3,HIGH);

      } else if (S0==0 && S1==0) {

            //follower moving towads right, stop left motor

            digitalWrite(MOT0,LOW);

            digitalWrite(MOT1,LOW);

            digitalWrite(MOT2,LOW);

            digitalWrite(MOT3,HIGH);

      } else if (S3==0 && S4==0) {

            //follower moving towads left, stop right motor

            digitalWrite(MOT0,HIGH);

            digitalWrite(MOT1,LOW);

            digitalWrite(MOT2,LOW);

            //digitalWrite(MOT3,LOW);

            analogWrite(MOT3, 125);

      } else if (S4==0 && S5==0) {

            //follower moving towads left, stop right motor

            digitalWrite(MOT0,HIGH);

            digitalWrite(MOT1,LOW);

            digitalWrite(MOT2,LOW);

            digitalWrite(MOT3,LOW);

      } else if ( S4==1 && S5==0) {

            //follower moving towads left, stop right motor

            digitalWrite(MOT0,HIGH);

            digitalWrite(MOT1,LOW);

            digitalWrite(MOT2,LOW);

            digitalWrite(MOT3,LOW);

      } else if (S0==0 && S1==1) {

            //follower moving towads right, stop left motor

            digitalWrite(MOT0,LOW);

            digitalWrite(MOT1,LOW);

            digitalWrite(MOT2,LOW);

            digitalWrite(MOT3,HIGH);

      } else {

            //stop follower

            digitalWrite(MOT0,LOW);

            digitalWrite(MOT1,LOW);

            digitalWrite(MOT2,LOW);

            digitalWrite(MOT3,LOW);

      }

}   // end of the code

 So there we've it guys, a line following toy car. If you wish this Blog. Please do not forget to share with your friends.I will be able to see you soon with another Blog, till then MAKE A LINE FOLLOWER.
Hope You Enjoyed Working On this Project!!! 

Comments

amazon banner

Popular posts from this blog

Motion Detector Camera

Motion Detector With Photo Capture Camera   Hello friends!! Welcome to This Blog. In this Blog, we will make a motion sensor detector with photo capture using ESP32CAM and the PIR module. The logic behind is when the PIR sensor detects any motion, the ESP32CAM will start taking the pictures. So you can use this project as a security camera. In thisblog, I will share the circuitdiagram, Arduino sketch, and the component list, so after reading the complete article you can easily make this project. Now ESP32 CAM is a small camera module that has ESP32S chip on the back and some GPIO pins to connect peripherals and it also has a micro-SD card slot, where you can insert the micro-SD card and store the pictures. Now before going to the circuit diagram and Arduino sketch, let me give you a quick overview of this project.  Components Required ESP32-CAM  PIR Motion Sensor Module BC547 NPN Transistor 220ohm, 1k, 10k Resistor. LED 5-mm FTDI 232 USB to Serial Interface board 5 volt DC supply  The

Bidirectional Visitor Counter

Bidirectional Visitor Counter using Arduino A bidirectional visitor counter using Arduino may be a reliable circuit that takes over the task of counting variety of Persons/Visitors within the Room very accurately. if somebody enters into the space then the Counter is incremented by one and also leaves it might be incremented. MATERIALS REQUIRED: Arduino IR Module 16*2 LED 5V Relay Resistor(1K,220 ohm) Breadboard Jumper Wires The total number of persons inside the space is Shows on the 16X2 LCD module. The microcontroller does the work it receives the signals from the sensors, and this signals operated under the control of software which is stored in EPROM of Arduino. There are two IR Modules are used. first, one are often wont to count the amount of persons entering a hall within the up mode at the doorway gate. and therefore the other can count the amount of persons leaving the hall by decrementing the count at the exit gate. In this Project will helps to Wastage of electricity. In ou

Obstacle Avoiding Robot

Obstacle Avoiding Robot using Arduino and Ultrasonic Sensor A simple project on Obstacle Avoiding Robot is meant here. Robotics is a stimulating and fast growing field. Being a branch of engineering, the applications of robotics are increasing with the advancement of technology.The concept of Mobile Robot is fast evolving and therefore the number of mobile robots and their complexities are increasing with different applications. There are many kind of mobile robot navigation techniques like path planning, self – localization and map interpreting. An Obstacle Avoiding Robot may be a sort of autonomous mobile robot that avoids collision with unexpected obstacles. In this project, an Obstacle Avoiding Robot is supposed. It's an Arduino based robot that uses Ultrasonic range finder sensors to avoid collisions.  Components Required Arduino NANO or Uno  🛒 HC-SR04 Ultrasonic Sensor  🛒 LM298N Motor Driver Module  🛒 5V DC Motors  🛒 Battery  🛒 Wheels 🛒 Chassis  🛒 Jumper Wires  🛒 Circ