Line following robot code

Can someone please help me out about explain ing qtr library in detail…and how to use it in line following robot in order to use pololu qtr8A sensor…how to take left and righr turn using that sensor??


We include a sample routine and some tips you might find helpful for line following in the documentation we provide for the Arduino library for the QTR reflectance sensors. For a more in depth look into the concepts of line following, the line following example project in the 3pi Robot user’s guide might also be helpful. If there is something specific that is unclear, please let me know and I will try to clarify.


First of all thanks for taking time for me…i just want a simple line follower robot with only qtr sensor…here, in 3pi they have used 3pi library which i dont want to use…i have just learned abou callibration but how i can use it with motor driving left and right…means i dont want to take my sensor on lines with my hand…i want to take it automatically my motors…so help me out…and what values should i choose to take take left and right turns

I was pointing to the 3pi examples not as a direct source of code, but as documentation that explains the concept of line following in more depth. With those two documents as guides, you should be able to try and write your own code. You should also try writing code for your suggestion of making the robot move by itself when calibrating. If you have trouble with your code, you can post it here with a video or description of specific issues and might be able to give you further advice.


How can i calibrate sensor automatically by using only gear motors…is it complusion to use motor sheild with qtr sensor or servo??.please help me out with this code

It looks like you found a forum thread with some code for automatically calibrating a the qtr sensor on a robot.


Hey grant,
Thanks for your bot is working .but the problem is. My kp value is 0.124 and kd value is 2. If i increased kd , bot’s one wheel rotates. And i want a sharp 90 degree turn.what should i do?i have seen many post regarfing to sharp turn it indicates to increase kd value bcoz its a sudden change. Do this really matters.? Please help me out in sharp turns.

It sounds like you are talking about a 90 degree turn that is not a smooth curve. If that is the case, I recommend looking at the 3pi and Zumo maze following examples and see how they do turns. They do some processing to detect the 90 degree turn then call a separate turn function to execute the turn. If you want additional advice, you should post a video showing what your course looks like and what your robot is doing, as well as a clear description of what you are trying to make it do.