Basic Line following Robot with Arduino

Picture of Basic Line following Robot with Arduino
In this tutorial we are going to go over building a arduino line following robot using Proportional control as the control method. Similar to PID but simpler. I reccommend checking out the Wiki on both control systems.

Proprotional Control


Remove these adsRemove these ads by Signing Up

Step 1: Build list...

Picture of Build list...

1.   Arduino Uno or compatible                                                           

2.  Sparkfun Ardumotoshield                                          

3.  Pololu QTR-8RC Reflectance Sensor Array         

4. Robot chassis                                                                

5.  Jumper Wires                                                                

verything to build the robot except the line sensor can also be purchased as a discount bundle:
Zagros Robotics Beginning Robot Bundle (

Step 2: Assembly...

Picture of Assembly...
After assembling the chassis secure the battery, Arduino and Ardumoto shield to the chassis ( I used zip ties). Next secure the QTR sensor so that it is just slightly above the surface that the robot is going to be moving on. I used thin wire so that it was easy to adjust the sensors position but strong enough to hold it, as it might take some adjusting when tuning your completed robot. Also take notice of the position of the sensor, header pins towards the inside so that the sensor pins match the Arduino sketch.
gadriuno17 days ago

In connecting the ardumoto pins to the sensor array, did you have to solder the wires?

gadriuno17 days ago

In connecting the ardumoto pins to the sensor array, did you have to solder the wires?

elliot420622 days ago
How much was the total cost?
calmeida33 months ago
Hi, what do I need to change if I use a QTR-8A (analog) with a arduino uno and na arduino motor shield.
My problem is the basic programm (provided by Arduino) only recognised 4 sensor pin. Any help woulg be appreciated.
Regards in advanced
ppraça7 months ago
hi, can you help me with a very simple question. Where goes connect the 2 wires (red/white and black) attached to the ardumotor. plz answer my question or somebody else.

ZRob314 (author)  ppraça7 months ago
The red/white and black wires on my robot are not used in this tutorial. Those wires are to add more power to the motor drive if needed. I am already powering the arduino through the barrel jack which has enough power to run the arduino and the motors. Please refer to the schematic or look at this other tutorial that has a detailed drawing if your still confused about wiring the robot. -Atom

osas20111 months ago
Thanks for your help, finally got the robot working fine. check it out! lol
osas20111 months ago
Hi, I was playing with the position of the sensors, sometimes it works and follow the black line other times it doesn't. How do i go back in the code and change how far the sensor can pick up the black line? please help.
rgümüş11 months ago
Hi I cant' make my line following robot move. please help me to make it move. I would like to use 8 qtr sensors and motor driver. I couldn't make your codes work
ZRob314 (author)  rgümüş11 months ago
Do you have a specific problem or question about the setup?
osas20111 months ago
Hi, i finally got the code working, had to download all the libraries and put them in the arduino but now the robot is still not working. My prof said becuz i need an extra power supply to power the ardumoto and motors differently because the 6V battery is not enough. Do you think that might be the problem the motors did not move?? Pleaseee help!!
ZRob314 (author)  osas20111 months ago
Have you tried fresh batteries (they don't last very long under use)? Have you tried running the motors manually at full speed?

You can use the motor control example on our website to confirm your robot motors are not binding and everything else is working before attempting the line following:

could you explain how does the code work for this robot. because im building the project for my class
Hi, I came accorss your post when I was doing research on arduino codes. I have the exact set up you have but I don't have any idea how to write a code. I'm useing the Arduino Uno R3, Ardumoto Motor Shield and the QTR-8 Sensor Array. Is there only one code you need to use, a code for each component or what. I'm really not sure what to do. What code will make the robot follow a black line of tape smoothly and quickly? What do I need to do to get the code into the robot?

ZRob314 (author) 1 year ago
With the Arduino look at the BlueSmirf of BlueMate

These are pretty easy to connect up and get going. XBee is also a good and even easier option:
osas2011 year ago
Thanks, I can see you use a Pololu QTR-8RC Reflectance Sensor, for my project i am required to have at least 1 sensor and a 1 communication method. Like Bluetooth, Xbee, WIFI or wired communication. Just wondering with type of communication did you use in the robot? And if i were to try to implement any kind of communication would it change the program(sketch) needed or would it still remain the same. I'm sorry if my question doesn't seem clear. I'm so new to this :(
ZRob314 (author) 1 year ago
It should load fine in version 1.0 - the issue is probably the change in the file extentions. All of the files need to be placed in a folder with the same name as the sketch you are trying to load and run. Let us know if you have any other questions. The older sketches have an extention .pde.
osas2011 year ago
Hi!! I am very much like this robot here!! it's simple and looks beautiful. I am placing orders on the parts now, because i would love to build this, its a school project. I just got some question i and i hope you can help me out. what is the code you use for the Arduino to program it? and when you say the file doesn't work for the Arduino Ide 1.0 and above ## what exactly do you mean? do it mean i have to download an arduino program that is lower? I'm sorry i am just really new to this and i would greatly appreciate if you can guide me through the way please.

Get More Out of Instructables

Already have an Account?


PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!