Category Archives: Uncategorized

Making a line follower BOT

Making a line follower BOT

Line followers are one of the most prominent kinds of robot. They have existed for a very long time , however the technologies used for building them have changed rapidly. Earlier controller boards the size of bricks were used , but now they have shrunk and become tremendously powerful. Now , technology allows you to build a line follower in just under 10 minutes if you have all the parts for it. So enjoy building this quick and easy line follower. Have fun with this tutorial!

What are the stuff required to do this project?

Hardware :

  1. Arduino / Arduino Clone
  2. Two continuous rotation servo motors Continuous rotation servo.
  3. A ball caster : Ball caster.
  4. An infrared sensor array like this : Pololu QTR-8A IR sensor array OR a set of six IR Leds and Detectors.
  5. Resistors : 1K and 10K.
  6. Two robot wheels like this, select wheels after checking if they fit in the servo : Robot wheels.
  7. Chassis , usually a small acrylic board will do.
  8. Four AA duracell batteries and battery holder.

Software :

  1. Arduino IDE : Arduino.

So how does it work?

The working of a line follower robot is pretty straight forward. These robots have the capability to detect a black/dark line on a lighter surface depending on the contrast. They estimate whether the line underneath them is shifting towards their left/right as they move over them. Based on that estimation they give respective signals to the motors to turn left/right so as to maintain a steady center with respect to the line.

These robots usually use an array of IR (Infrared) sensors in order to calculate the reflectance of the surface beneath them. The basic criteria being that : The black line will have a lesser reflectance value (black absorbs light) than the lighter surface around it. This low value of reflectance is the parameter used to detect the position of the line by the robot. The higher value of reflectance will be the surface around the line. So in this linear array of IR sensors, if the leftmost/rightmost IR sensor presents the low value for reflectance , then the black line is towards the left/right of the robot correspondingly.The controller then compensates for this by signalling the motor to go in the opposite direction of the line.


The IR sensor array consists of individual IR LEDs and IR photodiodes. The IR light emitted by the LED strikes the surface and is reflected back to the IR photodiode. The photodiode then gives an output voltage proportional to the reflectance of the surface (high value for light surface and low for black/dark surface).

Easy Line Follower

Step 1 (Optional) : Making the sensor array for the line follower (only if you don’t want to buy the pololu reflectance sensor)

In order to make an IR sensor array , take the six IR LEDs and connect them in parallel with each other. Now, take the IR photodiodes and place each of them just below the six IR LEDs. Wrap each pair together using black insulation tape leaving their tips exposed. Take these six pairs of IR LEDs and photodiodes and join them in a straight line, each pair should be 1.5cm apart from the next.




Step 2 : Assembling the components for the line follower

Take the piece of acrylic board and stick the servo motors to the left and right edges using hotglue/super glue. Then attach the ball caster on the opposite edge . Take the pololu IR sensor array or your own sensor array and stick it on top of the two servo motors using a small plastic / foam piece. The sensor must be positioned in such a way that it’s about 4-5mm from the ground for optimal performance.On the top side, stick the arduino board using double side tape, do the same for the battery holder. This is how it looks like :

Lf2.jpg Lf1

Step 3 : Connecting all the components together for the line follower

Setup the hardware connections with the arduino and the servo motors. The continuous rotation servo motors are those kinds of servo motors that cannot be controlled or set at a particular angle unlike normal servos. Servos have three wires coming from them : Red- Power , Black -Ground, White/Yellow- PWM /PPM Signal. The left servo motor (white/yellow wire) is hooked up to arduino digital pin 9 and right servo motor (white/yellow wire) to arduino digital pin 10. The black wires of both the motors are connected to arduino GND and the Red wires to the positive terminal of the battery holder.



Using Pololu QTR-8A Reflectance array sensor :
If you are using the pololu sensor, and you don’t need all the 8 IR detectors you can remove 2 of them by cutting at the indicated perforation line on the board. The code we are using is only for 6 of them. Then solder some header pins to the board for Vcc, Gnd and signals 1,2,3,4,5,6. Connect the Vcc and Gnd of this sensor to arduino’s Vcc and Gnd. The signals 1,2,..6 are connected to arduino’s analog input pins A0, A1, A2, …A5.

Using custom fabricated sensor array :
If you are using the custom fabricated sensor array, then short the anode terminals of all the IR LEDs together and connect it to the arduino Vcc through a 220Ohm resistor. Next , short the cathode terminals together and connect it to arduino Gnd. Now, connect a 10K resistor to the cathode of each of the IR photodiodes. Short the free ends of all the 10K resistors together and connect it to arduino Gnd. Now short the anode terminals of the IR photodiodes together and connect it to arduino Vcc. Lastly, connect a wire to the cathode of each of the IR photodiodes (between the cathode and the 10K resistor). Connect each of the wires in sequence to arduino’s analog input pins A0, A1,..A5.


 Step 4 : Uploading the code for your line follower

The code for the line follower can be found at the end. After uploading the code , you need to sweep/move the sensor array over the black line from left to right for roughly 3 seconds. This is done in order to calibrate and find the max and min values for reflectance. After that place the robot on the line and watch the bot follow it. If your using the pololu QTR-8A reflectance array sensor then no significant changes may be required, try to check the values coming from the sensor through the serial monitor. Based on those values adjust the values in the code correspondingly.

For those who made the custom board, find out the rough values of reflectance over the black line and the outer surface. Substitute these values in the code and calibrate it. You can use normal black insulation tape as the line for your line follower. The line follower in action ! EnjoYY!!



Line Follower Robot -Abhishek Sugam, Micosoft Student Partner, University of Washington, Seattle.

Quick and easy line following robot using an IR reflectance
array.Connect Vcc and Gnd to the Pololu QTR-8A sensor from 
the arduino. Connect the pins 1,2,3,... to arduino's analog
pins 0,1,2,3,4,5.
If the average of the 3 values of the sensors on the left is
greater than the average of those on the right, then the robot
moves left and vice versa.
NOTE : The values in the code for analog voltages would have 
to be modified if you are not using the Pololu QTR-8A reflectance
array sensor. Use trial and error to find out max and min 
values for your own IR array sensor.
#include <Servo.h> 

Servo left;
Servo right; 

int mid = 0;
int mn = 0;
int mx = 0;

void setup()

left.attach(9, 800, 2200); //left servo motor
right.attach(10, 800, 2200); //right servo motor


digitalWrite(13, LOW);

right.write(90);//stop signal
left.write(90);//stop signal

for(int i=0; i<5000; i++)
digitalWrite(13, HIGH);

int val = 0;
for(int j=0; j<=5; j++)//Calibrating the sensor, finding max and 
{                      //min reflectance values.
val = analogRead(j);
if(val >= mx)
mx = val;
if(val <= mn)
mn = val;

mid = ((mx + mn)/2);
digitalWrite(13, LOW);


void loop()

int s0 = 0;
int s1 = 0;
int s2 = 0;
int s3 = 0;
int s4 = 0;
int s5 = 0;

s0 = analogRead(0);//Signal pin 1 on the board
s1 = analogRead(1);//Signal pin 2 on the board
s2 = analogRead(2);//Signal pin 3 on the board
s3 = analogRead(3);//Signal pin 4 on the board
s4 = analogRead(4);//Signal pin 5 on the board
s5 = analogRead(5);//Signal pin 6 on the board

Serial.print("Mid: ");
Serial.print(" ");
Serial.print(" ");
Serial.print(" ");
Serial.print(" ");
Serial.print(" ");
Serial.print(" ");
Serial.print(" ");

right.write(180);//Move forward
left.write(0);//Move forward


if((((s0+s1+s2)/3)>(((s3+s4+s5)/3)+240)))//Move right
Serial.print(" RIGHT");

if((((s0+s1+s2)/3)<(((s3+s4+s5)/3)-240)))//Move left
Serial.print(" LEFT");

if((s0 > mid)&&(s5 > mid))//Stop if all the sensors give low 
{                         //reflectance values
Serial.print(" STOP");

for(int k=0; k<50; k++)
digitalWrite(13, HIGH);
digitalWrite(13, LOW);


Enigma in the Sparks


“Dude, are you crying??” said Dev

“Nah, I’m fine”, I said

“I have known you long enough to understand your expressions man, tell me what happened!”

“It’s nothing man, all good ”

“It’s about her isn’t it? What did she say?”


“Come on; let’s go for a stroll near the acad building!!”

We moved out of our hostel, and walked towards the acad building. I looked up the night sky; the moon was hiding in the loft. It was a dark, Serene night as the luminous moon gleamed and the white twinkling stars gave harmony at the black, blue sky. We continued to walk in silence; the moon exposed half its face peering quietly listening to human movements. We passed the PMC (as the BITians call it being an abbreviation for Piya Milan Chawk) and then finally Dev spoke.

“What’s the issue Yaar?? Tell me something at least!!”

“M fine.”

“Forget Mann dude!  You have already spent too much time on her!”

“I love her.”

“ Bhai ghass bh nai daal rahi hai terko ! How long has it been? “

“Eight Years”

“Eight Years!! How can you keep on loving a single girl for eight years, jab wo tumko bhao bhi nai de rai hai ?

“ 😦 you wont understand man !! ”

I had been talking to her for over a year now, I had always been hinting that I still love her but, then we would talk as if we were just friends. I thought slowly and steadily, she had started to admire me and had finally fallen in love with me. We used to have night long calls these days, words naturally flowed out of my mouth and after talking for six hours on a go I didn’t remember a single topic from our talks. Finally on 13th November, 2011 at 4:29 am she said

“I love you too, come meet me baby.”

I was enthralled, I was experiencing moments of ecstasy and my eyes were surely gleaming with surprise. After eight long years, the moment had finally come I was bouncing with joy. I could hardly wait for until the morning.

But a lady’s fancy is very expeditious; it plummets from admiration to love, from love to s#it, in a moment.

“I am sorry!!

I just swayed away last night; I can’t talk to you now.

Best of luck for your future


Read Mann’s message from the next morning. It was like a Maserati had crashed into my chest and my broken heart dripped blood like oil leaking from wherever it is oil leaks from. My broken heart was still and for a moment, i only felt numbness. And then an anger and sadness surged through me with so much power, I knew not what to do. My heart stopped beating, for it had only beaten for her. My mind went black, as did my heart. It was like being trapped alone in the darkest abyss with a sword pierced through my heart. This broken heart was silent, it can’t be seen but the blood bleeds inside.

We returned back to our hostels and I went to sleep, but sleep had already abandoned my eyes. I lay back on my bed staring at the ceiling. Eight years it had been and I could still recall the first time I saw her, it seemed like yesterday. As the first soft ray of the golden yellow sun oozed across the turquoise sky, I walked down the street awaiting the spectacular awakening of this bee-hive – The golmuri market.

As I moved down the street I saw a young girl walking with a blithe gait. She was a treasure of purity and enlightenment. Her raven-black hair though short, cut in bob cut was a rich shade of mahogany. It flowed to adorn her glowing, porcelain-like skin. Her eyes, framed by long lashes, were a twinkling, bright and seemed to brighten the world. Her slit-like eyes were a clouded hazel, and her thinly plucked eyebrows were shaped into a deceivingly perfect arch that followed the slight curve of her eye.  A straight nose, full lips as red as rose – she seemed the picture of perfection. Had she smiled, the world would sigh with contentment. Had she laughed, the world would laugh with her. And had she wept, the whole world would want to comfort her.

“Shall I compare thee to a summer’s day?” Shakespeare’s sonnet flashed in front of  my eyes.

I grant I never saw such a goddess, I not only lost my train of thought, I lost all coordination. I lost her in this bee-hive but she had already tickled my soul.

The next few weeks I came to the market many-a-times wishing to catch a glimpse of her. I just wished I could see this idyllic goddess just once but hard luck I never saw her again. Now the vacations were about to end and our new session was going to start. Another week of roaming in the market but I couldn’t see her again. Finally my school had reopened and I went to my new class “VII A”, sat on the first bench. The teacher started taking the attendance calling out the names,


“Present”, I responded

The teacher continued calling out the names and I sat on the bench still mesmerized by the beauty of my mystery girl.


“Present”, said a voice which sounded more pleasant than music. I turned around and there she was smiling. Our gazes met and locked, sweeping me out of reality on a tidal wave of emotion!!!!!!!