Fast line follower with products from Pololu


I’m an IT teacher at a technical and vocational high school in Turkey. We have designed a line follower robot which we used mainly Pololu products on, and it won the first prize at The 3rd National Robot Contest (6 March 2009).

Thanks to Pololu for compact, high quality and inexpensive products, extensive stock and fast shipping.

Motor: Pololu 30:1 Micro Metal Gearmotor HP
Motor mounting brackets: Pololu Micro Metal Gearmotor Bracket Extended
Main wheels: Pololu Wheel 42x19mm
3rd wheel: Pololu Ball Caster with 3/8" Metal Ball
Motor driver: Pololu TB6612FNG Dual Motor Driver Carrier
Line sensors: Pololu QTR-8A Reflectance Sensor Array
Battery: ThunderPower 480 mAh 7.4V Li-Po
Microcontroller: Microchip PIC18F2550 at 20 MHz (10 ADC channels - 8 used)
Compiler: CCS C
PID period: 3ms
Velocity: 1.6 m/s
Turn radius: 25cm

Here’s the video:



Thanks for posting, and congratulations! Can you post a picture?

- Jan

Here is some pictures.


It looked really nice in the video! Do you know how fast it was driving in m/s?

EDIT - oops, I missed your 1.6 m/s in the original post. Is that the speed you get with the motors at 100%, or could it possibly go faster? Have you tried it on tighter turns?


1.6 m/s is average speed on the running track. Base motor speed is 60% of full speed. We haven’t tried it on turns with less than 25 cm radius. But I think it’s possible at approximately same speed with shorter PID period and more traction at wheels. We will be entering to another competition next weekend. So we will have chance to try this week.


Great that you won with the Pololu products! The video and the pictures look great!

Good Job! :smiley:

Hello Cenkk

I want to use PID control algorithm, because of the stability issues it solves, and to enable the following of more complicated line shapes.

My Line sensors; QTR-8A Reflectance Sensor.

I still can’t find how to translate a PID control algorithm to control the robot, the robot has two rear motors to control movement and directions. I even can’t find the algorithm it self.

Please, help me.


What are you using as your robot controller? You might find the PID line following section of the 3pi robot user’s guide helpful. To really use PID well, you want to find a way to convert the sensor readings into a single “position” value that tells you where the line is. Ideally, the function you come up with will vary monotonically as the sensor array sweeps over the line. That is to say, as you sweep across the line, you want your position value to always increase as you move in one direction and always decrease as you move in the other. If the position value sometimes increases and sometimes decreases for the same sweep direction, the PID algorithm could result in instability problems.

- Ben

Hello dicsum,

As Ben says, the 3pi robot user’s guide is very helpful, so we have benefited from it. Also you should check to the following links.

PID equation:
I have used PID equation in “type A” with only P and D term in our robot. The I term is not necessary for the line following algorithm.
e: Error reading from sensors
CO: PWM duty cycle for motors

A completed robot:
Good explanation of PID equation and analog sensors reading with source code.

Analog sensors setup: … periments/ … ors-setup/


Hello cenkk,

That desktop line follower looks very cute on that table! I’m curious about your drive train. Are the wheels being turned by motor shafts applied to the tires?

- Ryan

Cenk and Ben Thanks.

Sorry for my bad English.

I recommend that you review the web sites.
I wrote some code in some PID. I could not but be successful, especially in return. My program was more successful than previously. Even though I did not get the results you want great lengths. I took my time PID control. I was very tired.

Can I just wonder if the PID control routine Cenk? You look at the program for the problem easier to solve.

Features in the following way:
QTR-8A sensors card
motor speed: 1000 rpm
programming language: picbasic
microcontroller: 18f252
PWM frequency: 20000 Hz
Clock frequency 10Mhz

thank you.

Can you share your robots codes?
thanks, and good work

Hello to all,

Have you already study the codes written by Pololu and ChaN?
According to you, are there any missing points or mistakes on them? I don’t think so.

There are no magic codes available to get to drive any line follower robots. The codes depends on the design of robot. Also the design depends mostly on the running track. Actually our robot is not complicated, it is pretty simple.

In addition to my previous post:

  • Choosing the right motor controller IC:
    To get the robot to be reactive, the motor driver IC should brake the motors when the PWM signal goes low. Please have a look at the control function table in the file below.

  • A new method for us to calculating error:
    Daniel Alvarez from Spain uses a linear interpolation function for very accurate error estimation. We will try it definitely.

We are planning to use on our next robot as different from on this robot:

  • Pololu 42x19mm Wheel and Encoder Set
    By using encoders we will try to teach to our robot where are the turns and what should be the speed on each turns.

  • Pololu Adjustable Boost Regulator 4-25V
    It is definitely necessary to remain the PID parameters valid during almost all the battery life.

  • Pololu Pushbutton Power Switch SV
    We get bored with mechanical switches.

  • And finally a 32 bit microcontroller:
    We need a powerful MCU to make the PID and error calculation functions to be faster. We will use a ARM7 based header board with easy to use libraries. The Espardino micro2148 board has a LPC2148 MCU with 60 MIPS, 32K RAM and 512K flash (Woow…).


Hello RyanTM,

I have to ask you to excuse me that I haven’t noticed your post before.
Yes, you are totally right, the motor shafts applied to the tires on the desktop line follower robot. But it is not our robot. It builded by ChaN from Japan as already stated at website. This robot is just a reference for us.


Nice work! Thanks for posting.

Here is the new champion of Turkey.

Speed: 1.9m/s
Turn radius: 25cm

Powered by Pololu
Pololu TB6612FNG Dual Motor Driver Carrier with paralleled outputs for each motor
Pololu QTR-8A Reflectance Sensor Array
Pololu Pushbutton Power Switch SV
Pololu Mini Metal Gearmotor Bracket Pair
Pololu Ball Caster with 3/8" Metal Ball

Powered by Espardino micro2148
ARM7 board based on LPC2148

Powered by Banebots
BaneBots Wheel, 1-3/8" x 0.4", 1/2" Hex Mount, 30A, Black/Green
Hub, Hex, Series 40, Set Screw, 3mm Bore, 3 Wide

Powered by Maxon motor
Maxon 144325 - 12V, 2700 RPM

Congratulations on winning! Thanks posting the video and thanks for posting the parts list here, it’ll be a nice resource for someone trying to clone your bot or make a fast line follower.

How did you like the Espardino micro2148 board?

I’m asking because in a future robot you could probably replace your two TB6612FNG carriers, your Espardino, and your pushbutton power switch with a single Orangutan SVP-1284. The SVP has two TB6612FNG drivers built in to it, so you would be able to get the same performance out of your motors. The only thing is that the ATmega1284 (running at 20 MHz) is less powerful than the processor you used, so I’m wondering if you needed that power and what you used it for.


LPC2148 is a 32 bit 60MIPS MCU with 32K RAM, and Espardino supports microSD/SDHC cards. All the calculations on my code take just 125 microsecond on that MCU. It means I read the line 4 times in every one milimeter. I think a 8 bit 20 MIPS MCU can run the same code within 750 microsecond. Besides I log some important data in the 32K of RAM without effecting the normal operation of the robot and then dump it to a microSD card and then analyze it in the computer. This is very useful for debugging and finding out some bugs.

I burnt one of the motor drivers when the motor got stalled last week and I could easily replace it with a new one. So, Orangutan SVP-1284 Robot Controller is not suitable for me because I am not able to solder some SMD parts. When they are seperated parts, I also can replace the motor drivers with which are more powerful than them if I need . Besides I can place the parts on the body more properly than a single big package.

Espardino + two TB6612FNG carrier + pushbutton cost $75, but an Orangutan SVP-1284 Robot Controller costs $90. Everytime I need more power at low cost :slight_smile:

I think you could probably replace two MCUs on your controller with a powerful MCU like based on ARM7 :slight_smile:


Thanks for sharing your project. That course looks quite elaborate and exciting! What happens if two robots are almost the same speed and collide at the end?

- Jan

The race starts again at the start point if both of them lost the line after the collision. If that happens again, the robot which lost the line after its rival wins the race.