How to Make Line Follower Robot Using Arduino

145,899

51

46

Introduction: How to Make Line Follower Robot Using Arduino

About: I am Aarav Garg. I am 15y/o. I have a keen interest and passion for robotics and programming. I am the Founder of Tech Nuttiez, a startup that aims to educate the youth globally on technology! I am currently p…

In this instructable, I will teach you how to make a line follower robot using Arduino, which is a very common microcontroller board. The robot will use two infrared proximity sensors to detect the line and on the basis of input received from the sensors, the Arduino will direct the motors to move with the help of a motor shield.

Step 1: The Working

So there will be infrared proximity sensors placed on either side at the front of the robot. There are four possible sensor outcomes:-

Case 1:-

In this case, both the sensors don't detect the line. Both the motors rotate forward. As a result, the car moves forward.

Case 2:-

In this case, only the left sensor detects the line which means that the car requires to turn in the left direction. The left motor rotates backward and the right motor rotates forward. As a result, the car turns left.

Case 3:-

In this case, only the right sensor detects the line which means that the car requires to turn in the right direction. The left motor rotates forward and the right motor rotates backward. As a result, the car turns right.

Case 4:-

In this case, both the sensors detect the line. This means that the end has come. Both the motors stop rotating. As a result, the car stops.

That is the working structure of our robot...

Step 2: Parts Required

The parts required to build the robot are as follows:

  • Chassis (including motors and wheels )
  • Arduino Uno r3
  • L293D Motor Shield
  • IR Proximity Sensors (pair)
  • Jumper Wires
  • Switch
  • 4AA Battery Holder

Tools required:-

  • Soldering Iron
  • Hot Glue Gun
  • Screw Driver

I always prefer Quartz Components for buying electronic components!

Gather these parts and be ready for the next step ...

Step 3: Assemble the Chassis

Now, assemble your robot body. Everyone may have a different chassis. So assemble your chassis accordingly. Most of the chassis come with an instruction manual and even mine came with it so have a look at it and build your chassis accordingly. Then, attach the components to the chassis. Arduino, with the motor shield attached to it and also the battery holder must be fixed on the chassis.

Also, attach the proximity sensors at the front on either side, facing down. Make sure that they are attached at the corners...

Attach the switch too...

Solder wires to the motors and also switch and keep ready...

Step 4: Main Connections

Now do the connections as per the diagram above...

Left Sensor>>Arduino:-

  • Vcc>>5v
  • Gnd>>Gnd
  • Out>>A4

Right Sensor>>Arduino:-

  • Vcc>>5v
  • Gnd>>Gnd
  • Out>>A5

Connect the motors to the motor shield and plug the motor shield onto the Arduino board. Connect the battery holder to the shield through a switch. That's it for the connections, let's move on to the next step...

Step 5: Arduino Code

Now its time for the main thing- coding our robot...

Download my Arduino code file or write up your own code to get done...

Microcontroller Contest

Participated in the
Microcontroller Contest

3 People Made This Project!

Recommendations

  • Paint Challenge

    Paint Challenge
  • Unusual Uses Contest

    Unusual Uses Contest
  • Tiny Things Speed Challenge

    Tiny Things Speed Challenge

46 Comments

0
wahyukurniansyah88
wahyukurniansyah88

1 year ago

I have succeeded. My sensor light is on, but the sensor cannot detect the line. Are there errors in the program? Please help me please... fast respon
0
Aarav G
Aarav G

Reply 1 year ago

It depends.... The error might be hardware related too... You might have burnt your sensor hardware or they might be an error in the code.... Because you need to do minor changes to successfully run the provided code in your bot.... Kindly provide more details so that I can help you....

0
yasmeenmahmod18
yasmeenmahmod18

Reply 8 months ago

I have this problem also, my code is correct and my connection but the robot sometimes moved forward ,sometimes stop in its place and sometimes walking around itself

0
Aarav G
Aarav G

Reply 7 months ago

You need to adjust the code a little bit! Arduino code cannot always work in its direct and raw form! At times, necessary changes need to be made!

0
Аят Зейнеб
Аят Зейнеб

Reply 5 months ago

i have this problem too... and i'm wondering if you can help me if I send you the program that I created to make the robot following the line using three IR proximity sensors and the pictures of my robot

0
harshitkachhap8102004
harshitkachhap8102004

Question 5 months ago

Hey. You have attached the connection of sensor to the Arduino Uno board but in the video it had been attached to the motor shield is that correct ?

0
gangaputhraarun2001
gangaputhraarun2001

5 months ago

my sensors are working but problem is with motors they are responding partially,can u post the circuit diagram

0
Aarav G
Aarav G

Reply 5 months ago

Yeah, it is there above in the Instructable. Kindly have a look. The diagram is for sensors. The motors need to be plugged in the motor slots in the Arduino shield.

0
Lê1998
Lê1998

2 years ago

I have a library error "<AFMotor.h>" how to fix it?
0
Aarav G
Aarav G

Reply 2 years ago

For that, you have to first download the afmotor library from the internet. Just type in "afmotor library download" in the google search bar and the first link will take you to the GitHub repository from where you can download the library which will be in a zip form. Then you just have to add the library in the Arduino ide by clicking on the "add .zip library" option. Then just include the library in your sketch. Its simple!!!

0
Parwesh
Parwesh

Reply 1 year ago

Download adafruit-Adafruit-Motor-Shield-library

0
Kakdeka
Kakdeka

1 year ago on Step 5

How to code it with mblock?

0
Aarav G
Aarav G

Reply 1 year ago

I'm sorry but I have no idea regarding what mblock is.... You can use the Arduino IDE to code it.....

0
aniokesam
aniokesam

2 years ago

why was black insulation tape used?, could anything be used to make the line?

0
Aarav G
Aarav G

Best Answer 2 years ago

Ya u can use any kind of black paper or something that's black. I used a black PVC insulation tape because it reflects very less light so it avoids interference with the infrared sensors.

0
aniokesam
aniokesam

2 years ago

please what is the black line made of?

0
Aarav G
Aarav G

Answer 2 years ago

It is made of a black insulation tape :D

0
hamdef3000
hamdef3000

2 years ago

my robot doesn't perform well on 1 inch line width, it never complete a turning, its like the robot sensor already past the line before it successfully turning. i tweaked a lot of things, seems like i need to make my own algorithm

0
Aarav G
Aarav G

Reply 2 years ago

No, in your case the problem is not at all with the programming or the algorithm. It is just because of the nature and size of ur line. Also the placing of your sensors. Place them at the far front ends. Also ensure no sunlight is present at the place where you are testing the model because it intervenes with the functioning of the infrared proximity sensor. Ensure all these...