Project: Line tracing robot using Arduino

 Hello friends,and welcome back to teckhme there are a lot of robots in the field of robotics that students are interested in making. Some of the bots are the most common like Obstacle which avoids the bot and Line which follows the Arduino bot we are making today in every detail. The instructions are step by step. What do you need to do this? You need to know some basics of electronic coding, Arduino and communication. And if you are not familiar with all these things, you can learn them from our blog section. We have uploaded all the content there. Here you will learn all the things required to make this awesome robot. If you read the whole article carefully and follow all the steps, you will definitely learn and get it done.

Line Follower Robot is a very simple robot that follows a line, either a black line or a white line. This type of robot is very easy to build and is often the first choice for beginners who are just starting out with robotics. Basically, there are two types of line follower bots: one is the black line follower which follows the black line and the second is the white line follower which follows the white line. The line follower senses the line and follows it. Although the idea seems simple, with further development, robots similar to this are used in practice in many applications such as factory floor management robots or warehouse robots.

What is a line follower bot?

A line follower robot is an automated robot that can follow a single path that can be any color line. We mainly use black line and white surface so that the sensor can easily distinguish colors. The bot that follows the line is of many types depending on you available resources. You can make this robot only with sensor and motor driver. But it may not be accurate. That's why we always prefer the Arduino line that follows the robot. To make this robot maze solving software, you need to add some conditions to it like Right Dominated or Left Dominated. It looks like a small toy car, so some people called it to line up for the next car.

How does the line that follows the robot work?

First let me explain how the line should be. The line must be prepared carefully. No extra corners, no use of gray, don't make the pattern on the floor. When we put the robot car on the line that follows the surface. The vehicle sensor will detect the surface as either white or black. If both sensors are on black, the line follower will stop. And if both sensors are on the white surface, the robot will start to move.


The line follower bot starts running over the white surface when we put our bot on the white chat sheet. If any sensor comes close to the black line. The robot will turn against the direction of the line. For example, if the car turns to the left, the robot will gently slide to the right. And the same for the other sensor. All the main work is done here by the sensor. The sensor detects the color and then the robot reacts accordingly.

Infrared sensor has an infrared sensor that gives an output according to the light received in the photosensor. In black, the sensor will send a value of 0. Arduino received this value and then compare it to the specified condition and send the instructions according to the database. Arduino collects data from both sensors at the same time and compares the sensor's value with the previous one. Arduino sends instructions to the motor driver as an electrical signal of 3.3V which is lower to start the motor, now we have to connect the L298N to the motor. Because without the driver the Arduino cannot spin the motor. So here we are sharing all the details.

Line Tracking Robot Circuit Diagram:


Code of Line tracing robot

int val = 0 ;  
 int va2 = 0 ;  
 void setup()  
 {  
   Serial.begin(9600); // sensor buart rate  
   pinMode(2,INPUT);  // IR 1 SENSOR   
   pinMode(3,INPUT);  // IR 2 SENSOR   
   pinMode(5,OUTPUT); // LED PIN  
   pinMode(6,OUTPUT); // LED PIN  
   pinMode(7,OUTPUT); // LED PIN  
   pinMode(8,OUTPUT); // LED PIN  
   pinMode(9,OUTPUT);  // MOTOR 1 PIN  
   pinMode(10,OUTPUT); // MOTOR 1 PIN  
   pinMode(11,OUTPUT); // MOTOR 2 PIN  
   pinMode(12,OUTPUT); // MOTOR 2 PIN  
 }  
 void loop()   
 {  
  val = digitalRead(2); // IR 1 sensor output pin connected  
  va2 = digitalRead(3); // IR 2 sensor output pin connected  
  Serial.println(val); // see the value in serial mpnitor in Arduino IDE  
  Serial.println(va2); // see the value in serial mpnitor in Arduino IDE  
  delay(10);  
  if(val == 0 )       // RIGHT DIRECTION  
  {  
    digitalWrite(5,HIGH);  // LED ON  
    digitalWrite(6,LOW);  // LED OFF  
    digitalWrite(7,HIGH);  // LED ON  
    digitalWrite(8,LOW);  // LED OFF  
    digitalWrite(9,HIGH);  // MOTOR 1 HIGH  
    digitalWrite(10,LOW);  // MOTOR 1 LOW  
    digitalWrite(11,HIGH); // MOTOR 2 HIGH  
    digitalWrite(12,LOW);  // MOTOR 2 LOW  
  }  
  if(va2 == 0 )       // LEFT DIRECTION  
  {  
    digitalWrite(5,LOW);  // LED OFF  
    digitalWrite(6,HIGH);  // LED ON  
    digitalWrite(7,LOW);  // LED OFF  
    digitalWrite(8,HIGH);  // LED ON  
    digitalWrite(9,LOW);  // MOTOR LOW  
    digitalWrite(10,HIGH); // MOTOR HIGH  
    digitalWrite(11,LOW);  // MOTOR LOW  
    digitalWrite(12,HIGH); // MOTOR HIGH  
  }  
  if(val == 0 & va2 == 0 ) // FORWARD DIRECTION  
  {  
    digitalWrite(5,HIGH);  // LED ON  
    digitalWrite(6,LOW);  // LED OFF  
    digitalWrite(7,LOW);  // LED OFF  
    digitalWrite(8,HIGH);  // LED ON  
    digitalWrite(9,LOW);  // MOTOR 1 LOW  
    digitalWrite(10,HIGH); // MOTOR 1 HIGH  
    digitalWrite(11,HIGH); // MOTOR 2 HIGH  
    digitalWrite(12,LOW);  // MOTOR 2 LOW  
  }  
   if(val == 1 & va2 == 1 ) // STOP DIRECTION  
  {  
    digitalWrite(5,LOW);  // LED OFF  
    digitalWrite(6,LOW);  // LED OFF  
    digitalWrite(7,LOW);  // LED OFF  
    digitalWrite(8,LOW);  // LED OFF  
    digitalWrite(9,LOW);  // MOTOR 1 LOW  
    digitalWrite(10,LOW);  // MOTOR 1 LOW  
    digitalWrite(11,LOW);  // MOTOR 1 LOW  
    digitalWrite(12,LOW);  // MOTOR 1 LOW  
  }  
  }

Post a Comment

Previous Post Next Post