loading

09/07/2015

It has been a few years since we initially posted this Basic Line Following Robot with Arduino tutorial, and it appears so many people found it helpful that we should post an update which runs current Arduino Libraries, includes the newer robot kits that assemble faster/easier, and further explain some of these steps for those who may be very new to robots and Arduino.

In this tutorial, the goal and approach is the same as before. We are building and programming a robot that can follow a lined course with the use of an Arduino based micro controller system programmed to run a basic Proportional speed control. Proportional is a simpler and shortened version of a PID control. You can visit these Wikis to learn more about both systems :

Proportional Control

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

PID

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

Step 1: Build a course...

Before you can run the Basic Line Follower, you will need a lined course. Use white poster board, foam board, white board, expanded PVC, or even a white floor or table and create a line course with black electrical tape. You may have sharp corners, but it will run smoother if the turns are gradual. Keep a minimum of 6" between any meandering lines.

<p>how to make it using the official motor shield and magician chassis.</p>
<p>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!!!!!</p>
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.
Can i use adafruit motor shield? Insted of adumoto?
<p>Hey, I've got a problem. I did everything as it' s said in the tutorial but the robot is keep moving forward istead of following the line. Can someone help me?</p>
<p>i had connect the arduino n 10A motor shield to power window motor with additional 6v battery, why my speed motor are different between Left and Right</p>
<p>please help me</p>
<p>please help me</p>
<p>I am having trouble with powering the ardumoto. Where does the Vin for the ardumoto go to??</p>
<p>Vin is to power the motors from the L298. It has a max input of I believe 18vdc.</p><p>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. </p>
<p>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. </p>
<p>Hey! Sometimes it's helpful to scroll through the comments ;)<br>Do you get an error like the one described by SoonK further down? <br>Then this should solve it:<br></p><p>The problem appears, beacuse the code is for an older version of the Arduino program.<br>You <br> have to go into the imported library and open the files &quot;Button.h&quot;, <br>&quot;engine.h&quot; and and &quot;navigation.h&quot; and in each one replace the line <br>#include &quot;WProgram.h&quot;<br>with<br>#if defined(ARDUINO) &amp;&amp; ARDUINO &gt;= 100<br> #include &quot;Arduino.h&quot;<br>#else<br> #include &quot;WProgram.h&quot;<br>#endif<br><br>This <br> will solve the errors above, but a new error will occur saying theres <br>no &quot;wiring.h&quot;. To solve that problem go into the file <br>&quot;PololuQTRSensors.cpp&quot; and replace<br>#include &quot;wiring.h&quot;<br>with<br>#include &quot;wiring_private.h&quot;</p>
<p>Hello,</p><p>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</p>
<p>Hello, </p><p>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 --&gt; how do you do this?</p>
<p>Just make folder named &quot;QTRRC_Line_Follow&quot; and put the file inside... then it will open.</p>
Thanks for your help, finally got the robot working fine. <br>http://www.youtube.com/watch?v=KI_Y90df9Xw check it out! lol
<p>can you give me code?</p>
<p>Hi, Nice project!</p><p>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.</p><p>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.</p><p>Any help would be greatly appreciated.</p><p>Thanks.</p>
Did you go through the line sensor calibration procedure?
<p>Thanks for the response,</p><p>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.</p>
<p>Hey u3016798,</p><p>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.</p><p>Richard</p>
<p>Hello,</p><p>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?</p>
<p>i keep getting this error. i have already downloaded the library, and I am using the code that was in the QTRRCExamples folder. </p><p>In file included from QTRRC_Line_Follow.pde:1:</p><p>C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/Button.h:23:22: error: WProgram.h: No such file or directory</p><p>In file included from QTRRC_Line_Follow.pde:1:</p><p>C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/Button.h:34: error: expected `)' before 'buttonPin'</p><p>C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/Button.h:42: error: 'uint8_t' does not name a type</p><p>C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/Button.h:43: error: 'uint8_t' does not name a type</p><p>C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/Button.h:44: error: 'uint8_t' does not name a type</p><p>In file included from QTRRC_Line_Follow.pde:3:</p><p>C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/engine.h: In function 'void engineSetup()':</p><p>C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/engine.h:23: error: 'OUTPUT' was not declared in this scope</p><p>C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/engine.h:23: error: 'pinMode' was not declared in this scope</p><p>C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/engine.h: In function 'void motor(int, int)':</p><p>C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/engine.h:33: error: 'HIGH' was not declared in this scope</p><p>C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/engine.h:41: error: 'LOW' was not declared in this scope</p><p>C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/engine.h:45: error: 'analogWrite' was not declared in this scope</p><p>C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/engine.h:46: error: 'digitalWrite' was not declared in this scope</p><p>In file included from QTRRC_Line_Follow.pde:4:</p><p>C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/navigation.h: In function 'void calibrate(PololuQTRSensorsRC*)':</p><p>C:\Users\Student\Documents\Arduino\libraries\PololuQTRSensors/navigation.h:21: error: 'delay' was not declared in this scope</p><p>plz help</p>
<p>You probably solved it meanwhile, but I'll answer anyway for anybody who has the same problem (like me):</p><p>The problem appears, beacuse the code is for an older version of the Arduino program.<br>You have to go into the imported library and open the files &quot;Button.h&quot;, &quot;engine.h&quot; and and &quot;navigation.h&quot; and in each one replace the line <br>#include &quot;WProgram.h&quot;<br>with<br>#if defined(ARDUINO) &amp;&amp; ARDUINO &gt;= 100<br> #include &quot;Arduino.h&quot;<br>#else<br> #include &quot;WProgram.h&quot;<br>#endif<br><br>This will solve the errors above, but a new error will occur saying theres no &quot;wiring.h&quot;. To solve that problem go into the file &quot;PololuQTRSensors.cpp&quot; and replace<br>#include &quot;wiring.h&quot;<br>with<br>#include &quot;wiring_private.h&quot;<br><br>That should do it, worked for me!</p>
<p>if i chang th color of line for ex (white line and black background )what is chang in program?</p>
<p>I need arduino code for servomotor...!!Can nyone post...??</p>
<p>I need arduino code for servomotor...!!Can nyone post...??</p>
<p>I need arduino code for servomotor...!!Can nyone post...??</p>
<p>I need arduino code for servomotor...!!Can nyone post...??</p>
<p>Hello, </p><p>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 --&gt; how do you do this?</p>
<p>for coding of line follower click on:<br>http://ismrobotics.blogspot.in</p>
<p>i want to ask you guys that can I use the same code which is for arduino in freeduino??please reply</p>
We are unfamiliar with the Freeduino, but if it uses the Arduino development environment and has the same I/O it should work.
<p>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?</p>
<p>tell me the components used in making the line following robot</p>
<p>maja ko</p>
<p>maja ko</p>
<p>maja ko</p>
<p>Hello</p><p>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?</p>
<p>Hi What will happen if i use white tape on a black board??<br>will it still work? What part of my code must i change?<br><br>http://forum.arduino.cc/index.php?topic=257647.0</p>
<p>In connecting the ardumoto pins to the sensor array, did you have to solder the wires?</p>
<p>We just solder the headers on the sensor then use male to female jumper wires between the sensor array and the breadboard</p>
<p>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?</p>
<p>In connecting the ardumoto pins to the sensor array, did you have to solder the wires?</p>
How much was the total cost?
Hi, what do I need to change if I use a QTR-8A (analog) with a arduino uno and na arduino motor shield. <br>My problem is the basic programm (provided by Arduino) only recognised 4 sensor pin. Any help woulg be appreciated. <br>Regards in advanced
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. <br> <br>Thanks!
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 <br> <br>
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.
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

About This Instructable