loading
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

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

Everything to build the robot except the line sensor can also be purchased as a discount bundle:
Zagros Robotics Starter Kit - Magician Version (http://www.zagrosrobotics.com/shop/item.aspx?itemid=914)

or

Zagros Robotics Starter Kit - Gobbit Version (http://www.zagrosrobotics.com/shop/item.aspx?itemid=951)

 
1-40 of 49Next »
fuqthislab4 months ago

I am having trouble with powering the ardumoto. Where does the Vin for the ardumoto go to??

Vin is to power the motors from the L298. It has a max input of I believe 18vdc.

Here is tutorial on the board. Ignore the part where it says Vin is optional! If you really want you bot to move, it's not. If you are powering the yellow gear motors or micro gear motors, I recommend using at least 5 rechargeable AA or a 6v NiMH or NiCAD battery pack.

EstefaniaC5 months ago

Hi I am trying to do your project. I cant add the library to arduino. some people said they had to update the file to arduino.h, no sure what you mean by that. It would be great if you couls help, thax.

Hey! Sometimes it's helpful to scroll through the comments ;)
Do you get an error like the one described by SoonK further down?
Then this should solve it:

The problem appears, beacuse the code is for an older version of the Arduino program.
You
have to go into the imported library and open the files "Button.h",
"engine.h" and and "navigation.h" and in each one replace the line
#include "WProgram.h"
with
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

This
will solve the errors above, but a new error will occur saying theres
no "wiring.h". To solve that problem go into the file
"PololuQTRSensors.cpp" and replace
#include "wiring.h"
with
#include "wiring_private.h"

JackC45 months ago

Hello,

I want to know to program a bot when it approaches a t section.for eg. if bot approaches 1st t section then it should go forward and when it approaches 2nd t section it should turn left or right

Hello,

I am trying to do this project and could quite download the entire code. I am using the exact same parts. I am also using ArduinoUno R3 IDE1.0.6. Every time I try to open the the code it gives me an error that says that the file QTTRC Line follow needs to be inside a sketch folder Qttrc_Line_follow --> how do you do this?

Just make folder named "QTRRC_Line_Follow" and put the file inside... then it will open.

osas2012 years ago
Thanks for your help, finally got the robot working fine.
http://www.youtube.com/watch?v=KI_Y90df9Xw check it out! lol
trupeshr osas2016 months ago

can you give me code?

u301679810 months ago

Hi, Nice project!

I have replaced all wprogram.h and wiring.h references with arduino.h to bring the sketch up to spec with IDE 1.0.6, it is all verified and OK.

I am at the stage where I have uploaded the code and the robot seems to not be able to detect my line, it simply keeps driving forward (which i think is no-line detected behaviour). I have the sensor mounted about 3mm from the surface.

Any help would be greatly appreciated.

Thanks.

ZRob314 (author)  u301679810 months ago
Did you go through the line sensor calibration procedure?
u3016798 ZRob31410 months ago

Thanks for the response,

Yes I did, I found that the corrections it was making were too small to detect when it was travelling as fast as it was. I reigned it back in to a slower speed and saw better results.

Hey u3016798,

I also have my robot working but not following the line. How did you slow it down? Which program and what exactly did you change? Thanks in advance.

Richard

nkarlson u30167988 months ago

Hello,

when you changed it to arduino.h, is this library included in initial download or do you have to also find the arduino.h library?

SoonK11 months 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

You probably solved it meanwhile, but I'll answer anyway for anybody who has the same problem (like me):

The problem appears, beacuse the code is for an older version of the Arduino program.
You have to go into the imported library and open the files "Button.h", "engine.h" and and "navigation.h" and in each one replace the line
#include "WProgram.h"
with
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

This will solve the errors above, but a new error will occur saying theres no "wiring.h". To solve that problem go into the file "PololuQTRSensors.cpp" and replace
#include "wiring.h"
with
#include "wiring_private.h"

That should do it, worked for me!

if i chang th color of line for ex (white line and black background )what is chang in program?

Hello,

I am trying to do this project and could quite download the entire code. I am using the exact same parts. I am also using ArduinoUno R3 IDE1.0.6. Every time I try to open the the code it gives me an error that says that the file QTTRC Line follow needs to be inside a sketch folder Qttrc_Line_follow --> how do you do this?

NitishK27 months ago

for coding of line follower click on:
http://ismrobotics.blogspot.in

AnindyaB8 months ago

i want to ask you guys that can I use the same code which is for arduino in freeduino??please reply

ZRob314 (author)  AnindyaB8 months ago
We are unfamiliar with the Freeduino, but if it uses the Arduino development environment and has the same I/O it should work.
nkarlson8 months ago

Even though Button.h is included in the library you provided, it is not included in the sketch. Is there a reason you included it?

bass.shuru8 months ago

hi! i want to use Motor Driver 1A Dual TB6612FNG instead of ardumoto sheild , my question is will it work fine with this robot chassis or there will be any compliacations ?? pleaseeeee reply!!!!!

ZRob314 (author)  bass.shuru8 months ago
You should be able to use any motor driver you want that will meet the motor requirements (6vdc, 250mA max). The example program will need to be modified to work with your motor driver.

tell me the components used in making the line following robot

Tilokc10 months ago

maja ko

Tilokc10 months ago

maja ko

Tilokc10 months ago

maja ko

nkarlson1 year 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?

SuryaS1 year 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

gadriuno1 year ago

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

ZRob314 (author)  gadriuno1 year ago

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

bitblab1 year 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?

gadriuno1 year ago

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

elliot42061 year ago
How much was the total cost?
calmeida31 year 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

osas2012 years 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üş2 years 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
1-40 of 49Next »