Instructables
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 

http://en.wikipedia.org/wiki/Proportional_control

PID

http://en.wikipedia.org/wiki/PID_controller

http://www.societyofrobots.com/programming_PID.shtml


 
Remove these adsRemove these ads by Signing Up

Step 1: Build list...

Picture of Build list...

1.   Arduino Uno or compatible                                                http://www.zagrosrobotics.com/shop/item.aspx?itemid=868                     

2.  Sparkfun Ardumotoshield                                                    http://www.zagrosrobotics.com/shop/item.aspx?itemid=782

3.  Pololu QTR-8RC Reflectance Sensor Array                   http://www.zagrosrobotics.com/shop/item.aspx?itemid=896

4. Robot chassis                                                                          http://www.zagrosrobotics.com/shop/item.aspx?itemid=859

5.  Jumper Wires                                                                          http://www.zagrosrobotics.com/shop/item.aspx?itemid=834

E
verything to build the robot except the line sensor can also be purchased as a discount bundle:
Zagros Robotics Beginning Robot Bundle (http://www.zagrosrobotics.com/shop/item.aspx?itemid=914)

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.
SoonK26 days ago

i keep getting this error. i have already downloaded the library, and I am using the code that was in the QTRRCExamples folder.

In file included from QTRRC_Line_Follow.pde:1:

C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/Button.h:23:22: error: WProgram.h: No such file or directory

In file included from QTRRC_Line_Follow.pde:1:

C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/Button.h:34: error: expected `)' before 'buttonPin'

C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/Button.h:42: error: 'uint8_t' does not name a type

C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/Button.h:43: error: 'uint8_t' does not name a type

C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/Button.h:44: error: 'uint8_t' does not name a type

In file included from QTRRC_Line_Follow.pde:3:

C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/engine.h: In function 'void engineSetup()':

C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/engine.h:23: error: 'OUTPUT' was not declared in this scope

C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/engine.h:23: error: 'pinMode' was not declared in this scope

C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/engine.h: In function 'void motor(int, int)':

C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/engine.h:33: error: 'HIGH' was not declared in this scope

C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/engine.h:41: error: 'LOW' was not declared in this scope

C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/engine.h:45: error: 'analogWrite' was not declared in this scope

C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/engine.h:46: error: 'digitalWrite' was not declared in this scope

In file included from QTRRC_Line_Follow.pde:4:

C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/navigation.h: In function 'void calibrate(PololuQTRSensorsRC*)':

C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/navigation.h:21: error: 'delay' was not declared in this scope

plz help

nkarlson1 month ago

Hello

I have assembled the robot above and uploaded the files into my library on arduino. However the code is giving me problems asking about a WProgram.h. Do you think it is because I have a Mac?

SuryaS2 months ago

Hi What will happen if i use white tape on a black board??
will it still work? What part of my code must i change?

http://forum.arduino.cc/index.php?topic=257647.0

gadriuno6 months ago

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

ZRob314 (author)  gadriuno4 months ago

We just solder the headers on the sensor then use male to female jumper wires between the sensor array and the breadboard

bitblab5 months ago

I did everything in this tutorial. I also Had to update some of the files to arduino.h to make up for the updated IDE. I know little of arduino programing and programming in general. When I plug in the power the wheels don't move. I don't get it. Does anyone have a sketch for this that works I can get?

gadriuno6 months ago

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

elliot42067 months ago
How much was the total cost?
calmeida39 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ça1 year 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.

Thanks!
ZRob314 (author)  ppraça1 year 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. http://www.buildcircuit.com/how-to-make-an-easy-robot-using-arduino-android-amarino-ardumoto-and-magician-chassis/ -Atom

osas2011 year ago
Thanks for your help, finally got the robot working fine.
http://www.youtube.com/watch?v=KI_Y90df9Xw check it out! lol
osas2011 year 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üş1 year 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üş1 year ago
Do you have a specific problem or question about the setup?
osas2011 year 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)  osas2011 year 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:
http://www.zagrosrobotics.com/shop/custom.aspx?recid=48

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?

Cheers,
photo3.JPGphoto1.JPGphoto.JPG
ZRob314 (author) 1 year ago
With the Arduino look at the BlueSmirf of BlueMate
http://www.zagrosrobotics.com/shop/item.aspx?itemid=726

These are pretty easy to connect up and get going. XBee is also a good and even easier option:
http://www.zagrosrobotics.com/shop/item.aspx?itemid=819
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.