How to Make Line Follower Robot Using Arduino

68,552

18

33

About: I am a student...

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.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

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

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

1 Person Made This Project!

Recommendations

  • Made with Math Contest

    Made with Math Contest
  • Multi-Discipline Contest

    Multi-Discipline Contest
  • Robotics Contest

    Robotics Contest

33 Discussions

None
Aarav Ganiokesam

Best Answer 6 days ago

It is made of a black insulation tape :D

None
hamdef3000

6 weeks 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

1 reply
None
Aarav Ghamdef3000

Reply 6 weeks 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...

None
Aarav GLê1998

Reply 2 months 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!!!

None
sounddrill31

3 months ago

i want to do this project for a science exhibition.This is a well done and well explained project.Can i please get a circuit .fzz from fritzing to connect the motor shield to the motors?

1 reply
None
Aarav Gsounddrill31

Reply 2 months ago

Thanks for the compliment. I can surely provide you with the needed schematic of the motors to the motor shield. In the fritzing sketch, I have labeled the motor shield connectors and connected motor pins to the labels. In the motor shield, you have four motor connectors out of which you will be using only two connectors. So in the code, you can change whichever connectors you are going to use accordingly...

None
aaron.herrera

6 months ago

Hey i am going to make this for a student project and I was wondering do I only need the power source of the 4 AA batteries? Or do I need something to power the board as well?

2 replies
None
Aarav Gaaron.herrera

Reply 6 months ago

The 4 AA batteries can be used to power the board and the motors will be powered as well by them. So using 4 AA batteries are enough as the motor shield can provide the motors with enough current so you just have to connect the battery wires to the arduino power pins

None
MayankP37

Question 6 months ago on Step 5

How to determine the position and sensitivity of IR Sensor. And the width of the black line ??!!

2 answers
None
Aarav GMayankP37

Answer 6 months ago

Well see keep the width of the line about 5 to 6 cm and place your sensors at the left and right tips of the chassis on the front of the robot. Regarding g sensitivity, you can adjust it usi g the potentiometer present on the ir sensors until they give the needed output...

None
MayankP37Aarav G

Reply 6 months ago

Thanks a lot...!!! I made it. There was some changes needed in the code that's it.