Header Ads Widget

How to make line following robot using Arduino in Telugu

Hi friends, in this article we know about how to make a line following robot . And also know what is the circuit and code also what are the components required to de this project. 

Making video:



line following robot components:

  • Arduino                           BuyNow 
  • DC motors                      BuyNow 
  • L298N motor shield       BuyNow 
  • bredboard & wires         BuyNow 
These are the components required to do this project. After gathering all the components then connect the components regarding to below circuit 

If you want to buy Arduino components, I am giving my affiliate links. If you buy the components using my affiliate links, it will help to our channel and website growth. so do these small help.

 line following robot using Arduino circuit diagram:


How to make line following robot using Arduino

 upload the below code

line following robot using Arduino code :


#define in1 9
#define in2 8
#define in3 7
#define in4 6
#define enA 10
#define enB 5

 
 int M1_Speed = 150; // speed of motor 1 
 int M2_Speed = 150; // speed of motor 2
 int LeftRotationSpeed = 250;  // Left Rotation Speed
 int RightRotationSpeed = 250; // Right Rotation Speed
 
 
 void setup() {
   
  pinMode(in1,OUTPUT);
  pinMode(in2,OUTPUT);
  pinMode(in3,OUTPUT);
  pinMode(in4,OUTPUT);
   
    pinMode(enA,OUTPUT);
    pinMode(enB,OUTPUT);
 
      pinMode(A0, INPUT); // initialize Left sensor as an input
      pinMode(A1, INPUT); // initialize Right sensor as an input
 
}
 
void loop() {
 
  int LEFT_SENSOR = digitalRead(A0);
  int RIGHT_SENSOR = digitalRead(A1);
   
if(RIGHT_SENSOR==0 && LEFT_SENSOR==0) {
    forward(); //FORWARD
}
 
  else if(RIGHT_SENSOR==1 && LEFT_SENSOR==0) {
    right(); //Move Right
 }
 
  else if(RIGHT_SENSOR==0 && LEFT_SENSOR==1) {
    left(); //Move Left
}
 
  else if(RIGHT_SENSOR==1 && LEFT_SENSOR==1) {
    Stop();  //STOP
 }
}
 
 
 
void forward()
{
            digitalWrite(in1, HIGH);
            digitalWrite(in2, LOW);
            digitalWrite(in3, HIGH);
            digitalWrite(in4, LOW);
             
                analogWrite(enA, M1_Speed);
                analogWrite(enB, M2_Speed);
}
  
void backward()
{
            digitalWrite(in1, LOW);
            digitalWrite(in2, HIGH);
            digitalWrite(in3, LOW);
            digitalWrite(in4, HIGH);
             
                analogWrite(enA, M1_Speed);
                analogWrite(enB, M2_Speed);
}
  
void right()
{
            digitalWrite(in1, LOW);
            digitalWrite(in2, HIGH);
            digitalWrite(in3, HIGH);
            digitalWrite(in4, LOW);
             
                analogWrite(enA, LeftRotationSpeed);
                analogWrite(enB, RightRotationSpeed);
}
  
void left()
{
            digitalWrite(in1, HIGH);
            digitalWrite(in2, LOW);
            digitalWrite(in3, LOW);
            digitalWrite(in4, HIGH);
             
                analogWrite(enA, LeftRotationSpeed);
                analogWrite(enB, RightRotationSpeed);
}
  
void Stop()
{
            digitalWrite(in1, LOW);
            digitalWrite(in2, LOW);
            digitalWrite(in3, LOW);
            digitalWrite(in4, LOW);
}

you can directly downlaod this code just click on the download button  . DOWNLOAD 
if you have any doubts regarding to this project, contact me on Instagram or comment on YouTube video. I will help my best.

Post a Comment

0 Comments