Instructables

Arduino-based line follower robot using Pololu QTR-8RC line sensor

Picture of Arduino-based line follower robot using Pololu QTR-8RC line sensor
Faz3a-II (5).JPG
UPDATE FEB 2012: This guide is featured on Adafruit's blog
http://www.adafruit.com/blog/2012/02/14/arduino-based-line-follower-robot/

This is Faz3a II, my first line-following robot, which I also hope to use for maze-solving. I used the Arduino Uno, Adafruit motor shield, Pololu's QTR-8RC line sensors and motors. You can build a cheaper and lighter version of this robot using the Atmel Atmega328 and the L293D h-bridge. This robot weighs about 300gm and costs about $90 USD.

For my previous robot projects, I used an empty external hard disk enclosure as the robot platform. But for this robot, I am using a DVD case. All in all, I found the round shape of the DVD case a better choice for maneuverability.  Not to mention the low cost of DVD cases and ease of stacking layers to hold more parts, with the help of long screws and nuts.

For this project, my task was simplified by the availability of software libraries from Pololu and Adafruit for the sensor and motor shield respectively.

Of course I could have bought a robot kit but I want to be able to take my robot apart anytime to build another one or use the parts in a different project. So if your passion is robotics, consider getting a ready robot kit. 





PARTS LIST

ELECTRONICS
Arduino Uno
Adafruit motor shield
Pololu QTR-8RC line sensor. I used only 5 sensors.
Pololu 30:1 micro meta gearmotor X 2
7.2V (6 X AA NiMh batteries)

MISC
DVD case
Wires
Wire straps
3 long screws and about a dozen nuts to act as raisers. The length of the screws depends on the height of the battery brick. One thing to keep in mind when choosing the screws is to get the ones with smooth curved heads and not the flat ones. I use the screw heads as casters. 

SOFTWARE
Arduino IDE 1.0
Adafruit motor shield library
Pololu QTR-8RC Arduino library

REFERENCES
I wrote a guide no how to use and test the Pololu QTR-8RC line sensor.


 
 
Remove these adsRemove these ads by Signing Up
hassa5221 month ago

what is the value 2000 in line :- int error = position - 2000;

BuddyBoy111 months ago
Can you add a pinout to where to hook everything up?
fadel_19911 year ago
Hello Mr. techbitar

could you please help me to interface QTR-8RC sensor with an arduino Atmega 2560

In fact I downloaded the library of QTRSensors from the website of Pololu and it works, but the sensor does not work or even no LED is ON.

I have connected the 8 pins of the sensors to the digital pins in arduino and i connect the Vcc and Gnd to a battery of 5 V. Also, I have connected the LEDON pin in the sensor to a digital pin in arduino.
qhosanee1 year ago
Hi do you know if the qtr-8rc reflectance sensor array can be used in PIC microcontroller? It's very important, contact me
zelazem1 year ago
Could you still post a pin layout. Im having issues finding it in the code and the pictures dont really help. thanks
ik_ke_941 year ago
Did you used a voltage regulator? I used a 9.6V battery pack and when I put my 2 motors on the adafruit motor shield and The Pololu QTR-8RC sensor to each digital pin and the vcc with the 5 v on my MS, the power is removed.
hi can you add detailed instructions of the connections thanks
i really like that project sorry for my english i am from mexico
and i already have/bought the piezes can you give me detailled instrcucions of how to construct thanks
ik_ke_941 year ago
My English is not so good but I do my best!

I find you tutorial very good but I have a question

How do you connect your battery pack with your motor shield, because I can't see it on your pictures?
cheo_e2 years ago
i have a question about the sensor output:

how do you calculate the output of the sensors?

0*value0 + 1000*value1 + 2000*value2 + ...
--------------------------------------------
value0 + value1 + value2 + ...

is that correct?
How do you wide the motors and line sensor?
techbitar (author)  Bigbadwolf_argh2 years ago
If you review my code you will see which pins are doing what.
What exactly assigns or in what units are
#define KP .2
#define KD 5
Got a little lost right there O: BTW excellent robot! Very fast
techbitar (author)  AndresGalaviz2 years ago
These are constants you can experiment with for best PID results. There are plenty of excellent tutorials out there to explain PID controllers. See link below to a site had in my fav list but there are plenty of PID guides that can explain with varying degrees of detail. It's not necessary to understand the theory behind PID, just how to apply it for optimum results. For my robot, the K values are typically tweaked via experimentation.

http://www.chibots.org/index.php?q=node/339
Thank you very much, that link was of great assistance for my project.
techbitar (author)  AndresGalaviz2 years ago
super :)
kumaran2012 years ago
Hi,
I have arduino UNO, Pololu QTR 8 RC sensor array, MOTOR DRIVER 1A dual tb6612fng, two geared motor can u help me with procedure and coding for line follower.
techbitar (author)  kumaran2012 years ago
You will find plenty of useful info in this guide.
Nice work! But I don't see how you kept the Arduino from resting with only 7.2V supplied? O.o
techbitar (author)  TedRobotBuilder2 years ago
Thanks.

As for resetting concerns, let's analyze the robot:

-- Arduino Uno: 5V @ 500 mA (max)

-- Motors: 6V @ 40 mA free run / 360 mA stall X 2 = 720 mA (max)

500 + 720 = 1220 mA

I don't know how much the motor shield draws but when you consider I am using 6 X 2500 mAh NiMH 1.2 V AA batteries, that leaves me with 1280 mA. This is assuming max power draw from Arduino and the motors. There's plenty of power in the battery brick to power this robot.

The Uno really wants 9V, it's in the specs. The Uno's AVR chip wants 5V but the Uno's board has a regulator on it that expects to see about 9V (but can handle as much as 20V). I have built robots sending the Uno less then 9V but I normally run into resetting issues, like when the batteries start running down or the motors stall. If you aren't hitting any issues that's cool but you might be very close to the limit such that if you add a senor you could run into issues. Also, you could run the batteries longer if you had more headroom. Thanks for the feed back! :D
techbitar (author)  TedRobotBuilder2 years ago
http://arduino.cc/en/Main/ArduinoBoardUno

Arduino Uno Summary
Microcontroller ATmega328
Operating Voltage 5V
Input Voltage (recommended) 7-12V
Input Voltage (limits) 6-20V

Yeap, 7-12V recommended, your 7.2V is at the low side assuming you are using the Vin pin and not the 5V pin. I assume you have some big caps on your lines to stop any spikes.
techbitar (author)  TedRobotBuilder2 years ago
you will find the this links instructive as to the specs of the motor shield and the different ways it gets its power. hope this helps

http://www.ladyada.net/make/mshield/parts.html
techbitar (author)  TedRobotBuilder2 years ago
Also, most of my uses for the robot is demos/races lasting a few minutes so that's why I don't run into reset issues when using a fully charged power brick. But I am sure if I need to use the robot for extended periods, I will use a voltage booster to be on the safe side.
Pro

Get More Out of Instructables

Already have an Account?

close

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!