Robot - Line Follower


I began work on my first robot about two years ago. For no particular reason, I decided to begin with a line following robot and truth be told, my first attempt at building it was a complete failure. Looking back at my efforts, I believe, for a beginner, I was rather too ambitious. The circuit that I had designed had a bunch of unnecessary stuff which I then believed would give my robot an edge over the others. But it never worked and I had to start all over from scratch.

In my second attempt, I managed to get the robot on track. As delighted as I was with my first robot, it was nowhere near where I wanted it to be. I took it to a couple of competitions and not much to my surprise, it failed in both of them. I knew it was time to make some major changes in the design.

In my third attempt, (actually, it wasn’t the third, it was a revision of my second attempt) I updated the firmware and came up with a much more stable and accurate version. It performed well when tested and much to my delight, it finished first in two competitions and second in another. Though I was proud with what I had achieved, I felt that the robot was visually rather unappealing. And you’ll come to know why from its picture given above. It had wires running all over it and I had no other option but to rebuild it. A month or so later, I had the robot all ready and that is the current version of my first robot.

In this instructable I will guide you through the steps that I've followed in building the current version of my robot. It’s one of those robots which belong to the “scratch-built” category. You might find it difficult to find all the parts that I have used. So I insist you to read through the steps that I have followed, and then implement it in your own way with the parts that you've found.

This instructable requires that you are familiar with the following:
• Soldering and related equipments
• Hand tools like screwdrivers, wire cutters and strippers
• Reading schematics and connection diagrams
• C/C++ programming for AVR microcontrollers (optional)
Remove these adsRemove these ads by Signing Up
1-40 of 45Next »
m_a_k11 days ago


could you send me the hex file of this robot? please!!!

midhun_s (author)  m_a_k10 days ago
Download the program.rar file from Step 17. You will find the .hex file in it.
m_a_k midhun_s8 days ago

thank you very much but i can't find it.could you send it to gmail is

r_danesh1 month ago

I run the sonssors in bread board but it doesn't work what should i do?

bsingh213 months ago
The fuse bits not working! But I checked my MCU fuse bit using extreme burner. Low fuse bit is 0xE1 and high is 0x99. Is it right if not tell fuse bit in extreme burner. Thank you.
gulati_ishank3 months ago

A great tutorial but i have a query, what changes i would have to make if i am not using mcu's adc?

midhun_s (author)  gulati_ishank3 months ago

You could use potentiometers instead of the resistors that I've used in the sensor array. Thereby you can adjust the threshold manually. You can connect pins from the sensor array directly to any port of your mcu.

Thanks for prompt reply...

I have aleady done that but i am confused with code.

What changes should i make in the code?

midhun_s (author)  gulati_ishank3 months ago

Read data from the sensors to any port of the mcu. This data is equivalent to the binary value obtained using the get_sensors_binary() command. You won't have to use the sensors.h library except for the count_binary() command.

sunil934 months ago

by far the best tutorial on Line following robot that i have come across.......great work midhun

bsingh214 months ago
Can I make this using arduino uno? if I can please give me full details. And please tell me how to contact you.
Thank you
jaseel15 months ago
muralysunam made it!5 months ago

I made this line follower robot with PIC 16F877a. I would like to say that its incredible experience. Thank you Midhun_s for all you help. I made it and trying to integrate maze solving robot too. I changed some parts of algorithm too. Thank you. :)


Nice article. Can I make this using Arduino? I was thinking to use 5 sensors because my track seem to be like(image).

midhun_s (author)  suyashbansal266 months ago

I think it is possible.

I was wondering whether the Sensor array will work on Arduino?

I am having trouble with my current sensor array so I was thinking to make something like yours.
midhun_s (author)  suyashbansal266 months ago

I don't see why not. You can connect any six pins (among the eight) from the sensor array to your arduino analog pins. You can use a digital pin for the front sensor.

Thats fine. But how will the header files(sensors.h) work on Arduino?
midhun_s (author)  suyashbansal266 months ago

You cannot use the library as such on Arduino. It won't work. But you can copy the header files and function definitions from the <sensors.h> and you can use them on Arduino. You can skip the sensor initialization and analog_read() routines as it is already present. This method can be used for other libraries too.(eg. pushbutton)

mrahman208 months ago
Would you please tell me about the use of 9th cell? I went through the page. It is really fantastic. But I could not understand why you used 9th cell in sesor design. Would you explain in detail?
midhun_s (author)  mrahman208 months ago
The 9th sensor comes in handy when the robot detects an intersection. It checks whether there exists a forward path. If it finds one, the robot will skip the turn and moves forward. If it does not, then the robot will take the turn.
Take a look at the algorithm that I've used (it's in Step 24) and also the readings from the sensors (you can find that on Step 33).
Sayem8 months ago
Can you explain the design of sensor array? it is not clear to me.
jaseel19 months ago
midhun_s, Can I convert this robot into line maze solving robot?

can u give details of line maze slving robot

midhun_s (author)  jaseel19 months ago
Yes you can. All you need to do is modify the main() routine to turn this robot into a line-maze solver. I haven't currently tested this one but I'm sure there are articles on the web explaining the algorithm for a  line maze solver.
jaseel110 months ago
I assembled and programmed this robot.
but not works.
I didn't get anything in display.

how to troubleshoot?
midhun_s (author)  jaseel110 months ago
Test the LCD separately. Make sure that the data and control pins are connected as shown in Step 9 and don't forget to adjust the contrast pot.
jaseel1 midhun_s10 months ago
I Tested using 3 LCD displays,
what is the use of 4 switches?
midhun_s (author)  jaseel110 months ago
4 switches are used to get input from the user. In Step 32 you'll find how the sensors are calibrated and how the switches are used.
Priyandan10 months ago
Instead of Atmega32 what other micro controllers can u use
midhun_s (author)  Priyandan10 months ago
If you're following the same design for the circuit that I've described above, you can choose an Atmega16 instead.
Priyandan10 months ago
hey dude. I am also building a robot for a fest. I am planning to build something similar to yours. can u pls help me. Tell me a way of contacting u
khan1211 months ago
Thanks for such a great instructable, I wanted to ask you a question that can I change the IR Array to the specs of a give width track by tweaking or editing the code, or do i have to overall change the distance between the IR`s please will be waiting for your reply.
midhun_s (author)  khan1211 months ago
The distance between the IRs were chosen for a track width of 3cm but any value between 2 and 4 will work fine. You might consider editing the code if the track width is outside of that range.
ygrowup8612 months ago
can i get ur email id
Wow! Great instructable.
meanpc1 year ago
Fantastic documentation and media for this build. I especially liked the work you put into demonstrating how the line following actually works on different types of lines and turns. Very well done - thanks for the time you put into this.
midhun_s (author)  meanpc1 year ago
Thanks for the feedback.
najito1 year ago
hmm.i am 10 years old and i may try to simulate it on html code
dieginho121 year ago
motor drive module? how as works?
midhun_s (author)  dieginho121 year ago
The motor driver module makes it easy to control high power motors with a microcontroller.The motor driver is basically an H-bridge circuit (shown in the picture below).

When S1 and S2 are closed, the motor runs in one direction and when S3 and S4 are closed, the direction of rotation of the motor reverses. If we switch S1 and S2 (or S3 and S4) between close and open positions, we can control the speed at which the motor runs.
The module that I've used has got a pair of these H-bridges and they can be controlled independently.
1-40 of 45Next »