in

Line follower robot with Arduino

Arduino line follower

A robot which follows the line is known as a line follower robot. in this instructional exercise, we are going to make a Line follower robot with 5 sensor cluster Arduino robot. as we as a whole the basic standard of line follower robot. it pursues the dark line with the assistance of some sensor joined to the robot. this sensor help to discover the way to the robot. it is a straightforward robot which uses the pushbutton interfacing idea. in this, we use IR sensor rather than pushbutton yet the idea is the equivalent for line follower robot moreover.

Working of line follower robot:-

it’s having some IR sensor which recognizes the highly contrasting shading. IR sensor having an IR transmitter and recipient together. In the IR sensor transmitter transmit the infrared Rays, and the collector gets these Rays. at the point when the Sensor is on the white surface, it reflects back the infrared beams and these reason-giving us high or 5v voltage in the yield. what’s more, when the sensor is on dim shading particularly on dark it ingests the light and sensor will utilize a 0 rationale it means low or 0v at the yield.

on this guideline, our line follower robot works. at the point when the sensor on the dark line it gives some an instruction to the Arduino or some other microcontroller which we are utilizing in the line follower robot. at that point, we take a condition as indicated by the yield of the sensor. for instance:- if the center sensor is on the dark line and another sensor on the white then the robot will push ahead. what’s more, there might be numerous conditions in the program to make your line follower robot. so how about we begin with the circuit chart and code for the robot.

CIrcuit diagram for line follower robot

Do the connection according to the circuit diagram

Code for Line follower robot

void setup()

{

// put your setup code here, to run once:

pinMode(2, INPUT_PULLUP);

pinMode(3, INPUT_PULLUP);

pinMode(4, INPUT_PULLUP);

pinMode(5, INPUT_PULLUP);

pinMode(6, INPUT_PULLUP);

pinMode(7, OUTPUT);

pinMode(8, OUTPUT);

pinMode(9, OUTPUT);

pinMode(10, OUTPUT);

}

void loop() {

int L= digitalRead(2); //sensor 1

int AL= digitalRead(3); //sensor 2

int M= digitalRead(4); //sensor 3

int AR= digitalRead(5); //sensor 4

int R= digitalRead(6); //sensor 5

 

 

if (L==HIGH && AL==HIGH && M==LOW && AR==HIGH && R==HIGH)

{

digitalWrite(7, HIGH);   //motor 2

digitalWrite(8, LOW);             //FORWARD

digitalWrite(9, HIGH);   //motor 2

digitalWrite(10, LOW);

}

 

else if(L==HIGH && AL==HIGH && M==HIGH && AR==LOW && R==HIGH)

{

 

digitalWrite(7, LOW);   //motor 2

digitalWrite(8, HIGH);             //RIGHT

digitalWrite(9, HIGH);   //motor 2

digitalWrite(10, LOW);

}

else if(L==HIGH && AL==HIGH && M==LOW && AR==LOW && R==HIGH)

{

 

digitalWrite(7, LOW);   //motor 2

digitalWrite(8, HIGH);             //RIGHT

digitalWrite(9, HIGH);   //motor 2

digitalWrite(10, LOW);

}

else if(L==HIGH && AL==HIGH && M==HIGH && AR==LOW && R==LOW)

{

 

digitalWrite(7, LOW);   //motor 2

digitalWrite(8, HIGH);             //RIGHT

digitalWrite(9, HIGH);   //motor 2

digitalWrite(10, LOW);

}

else if(L==HIGH && AL==LOW && M==HIGH && AR==HIGH && R==HIGH)

{

 

digitalWrite(7, HIGH);   //motor 2

digitalWrite(8, LOW);             //LEFT

digitalWrite(9, LOW);   //motor 2

digitalWrite(10, HIGH);

}

else if(L==HIGH && AL==LOW && M==LOW && AR==HIGH && R==HIGH)

{

 

digitalWrite(7, HIGH);   //motor 2

digitalWrite(8, LOW);             //LEFT

digitalWrite(9, LOW);   //motor 2

digitalWrite(10, HIGH);

}

else if(L==LOW && AL==LOW && M==HIGH && AR==HIGH && R==HIGH)

{

 

digitalWrite(7, LOW);   //motor 2

digitalWrite(8, HIGH);             //RIGHT

digitalWrite(9, HIGH);   //motor 2

digitalWrite(10, LOW);

}

else if(L==LOW && AL==LOW && M==HIGH && AR==LOW && R==LOW)

{

 

digitalWrite(7, LOW);   //motor 2

digitalWrite(8, LOW);             //RIGHT

digitalWrite(9, LOW);   //motor 2

digitalWrite(10, LOW);

}

else if(L==HIGH && AL==HIGH && M==HIGH && AR==HIGH && R==HIGH)

{

 

digitalWrite(7, LOW);   //motor 2

digitalWrite(8, HIGH);             //RIGHT

digitalWrite(9, HIGH);   //motor 2

digitalWrite(10, LOW);

}

else if(L==LOW && AL==LOW && M==LOW && AR==LOW && R==LOW)

{

 

digitalWrite(7, LOW);   //motor 2

digitalWrite(8, LOW);             //RIGHT

digitalWrite(9, LOW);   //motor 2

digitalWrite(10, LOW);

}

else

{

digitalWrite(7, HIGH);   //motor 1

digitalWrite(8, LOW);                 //STOP

digitalWrite(9, HIGH  );   //motor 2

digitalWrite(10, LOW);

}

}

Upload the code into the Arduino Uno and make the connections.

What do you think?

3 points
Upvote Downvote

Written by shahid

2 Comments

Leave a Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

IOT Control Home Automation Using NodeMcu

Mini bot