I made a line follower robot with PIC16F84A microprocessor equipped with 4 IR sensors. This robot can run on the black and white lines.

Step 1: First Step

Before everything you must know how to make a Printed Circuit Board and how to solder components on it. You also need to know how to program a PIC16F84A IC.
Here are the links to good instructables about making a PCB and Soldering:

Step 2: Things You Need

To make this robot you need the following things:
  • Some copper board
  • Printed circuits
  • Saw
  • Sandpaper
  • Iron
  • Circuit board acid
  • 1mm drill
  • Soldering oil
  • Soldering wire
  • Soldering iron
  • Wire cutter
  • Some wire
  • 2x Plastic wheels
  • 1x Spherical front wheel
  • Glue
Circuit boards components:
  • A 4 AA battery holder
  • U1 = PIC16F84A Microcontroller + Socket
  • U2 = 7805 = 5V Voltage Regulator
  • U3 = LM324 Comparator
  • U4 = L298 Motor Driver + Aluminum Radiator
  • XT = 4MHz Crystal
  • C1 = C2 = 22pF Ceramic Capacitors
  • C3 = 100uF Electrolyte Capacitor
  • C4 = C5 = 100nF Ceramic Capacitors (104)
  • D = 8 x 1N4148 Diodes
  • R1 = 4.7K Resistor
  • R2 = R3 = 10K Resistors
  • R4 = R5 = R6 = R7 = 1K Resistors
  • R8 = 10K Resistor
  • R9 = 1K Resistor
  • R10 = R11 = 47K Resistors
  • R12 = R13 = R14 = R15 = 100ohm Resistors
  • R16 = R17 = R18 = R19 = 10K Resistors
  • RP = LP = MP = FP = 10K Potentiometers
  • L Motor = R Motor = 60rpm MiniMotors with Gearbox (6V)
  • R Sensor = L Sensor = M Sensor = F Sensor = TCRT5000 Infrared Sensors
  • ModeLED = LBLED = RBLED = Small Red LEDs
  • LFLED = RFLED = Small Green LEDs
  • Mode = Left = Right = Small Buttons
  • SW = Toggle Switch = On/Off Switch
  • J = Jumper = A piece of wire
PCB.pdf(595x842) 101 KB

Step 3: Making the Circuit Boards

Picture of Making the Circuit Boards

Print the circuits on a glossy paper with a laser printer. Cut copper boards, clear them with sandpaper and put the printed circuits on them. After pressing the hot iron on the boards remove the papers and soak boards in acid, wait till visible copper disappears. Wash the boards, drill the holes and clear them with sandpaper.

* I have only a symbolic diagram of the robot that you can see here.

Step 4: Soldering Components

Solder all parts on the boards.
Be careful of the correct direction of components.
Use a socket for PIC16F84A IC.
Solder motors and battery holder on the back side of the Bottom board and put some pieces of paper around motors to avoid unexpected contacts in the circuit.
Solder C4 and C5 right on the motors.
Put a piece of paper among potentiometers legs to avoid contacts.

Step 5: Soldering All Together

Picture of Soldering All Together
Right View.JPG
Front Board.JPG
Back Board 1.JPG
Front-Bottom Boards Connections.JPG
Battery Holder Connections.JPG
Connect terminals with same name on the boards together by some piece of wires (You can use the extra legs of the other components).
Solder the Back board to the Top board.
Solder the Front board to the Top board.
Bend the wires and put three boards on the battery holder and solder Front board and Back board to the Bottom board (Use some long flexible wires to contact terminals of the Back and Bottom boards).
Connect + terminal on the Top board to the battery holders + pole.

Step 6: Wheels

Picture of Wheels
Left View.JPG
Right Motor.JPG
Connect 2 plastic wheels to the motors and cover them with a rubber band.
Attach a wheel to the Back board in front of the robot with some glue, I used a dead LED as front wheel but it makes the robot move slow and I recommend to use a spherical wheel.
Cover the gearboxes with sheets of thin plastic.

Step 7: Programming the Robot

Picture of Programming the Robot
Download the robot program (Code.hex) and program the PIC16F84A IC.

Step 8: RUN

Picture of RUN
Put 4 AA batteries into the battery holder, make a path, and turn on the robot.
If the robot does not work check soldering carefully.
Now you must adjust potentiometers to robot be able to detect black and white areas. Turn all potentiometers to leftmost position then turn back about 90 degrees to the right. Hold the robot on the line, move it over a turning if the motors state does not changed change the potentiometers value.
Now put the robot on the path to follow it.

Step 9: Custom Movement

You can define a custom movement for the robot by pressing the Mode button.
When the Mode LED is off the robot is on its default state.
After pressing the Mode button the Mode LED turns on, now you can hold the robot in different states and change the state of the motors depend on their default state by Left and Right buttons.
After pressing the Mode button again the Mode LED starts blinking, now you can hold the robot in different states and change the state of the motors depend on values of the sensors by the Left and Right buttons.
To switch to default state, press Mode button again.
There are four states for the motors:
  1. Default state
  2. Forward (Green LED is on)
  3. Backward (Red LED is on)
  4. Stop (Both Green and Red LEDs are on)

Step 10: How it works?

This robot has 4 IR sensors that scan the path.
If the Right and Left sensors has same values and the values of them are different from the Middle or Front sensors the robot is on the line and motors running forward. Else the robot is out of line so the robot keeps moving till one of  the side sensors value changes then it turns to the direction that its sensor value changed.
You can read the program source code (Code.bas) to understand it better.
1-40 of 154Next »
gkas26 days ago
sj2992 months ago

i made a line follower robot but i dont know the conf of IR sensors i used bascom avr 8

dear sir please me give a market price of following component

1)A 4 AA battery holder(with image)

2)PIC16F84A Microcontroller + Socket(with image)

3)LM324 Comparator(with image)

4)L298 Motor Driver + Aluminum Radiator(with image)

5)4MHz Crystal(with image)

6)TCRT5000 Infrared Sensors(with image)

7)60rpm MiniMotors with Gearbox (6V)

vahid_you2004 (author)  darshan.vadher.95 months ago

They are all typical electronic components you can find in any electronic components shop.

thanks for giving my first question's answer !!!!!!!!!!!!!!!!!

darshv5 months ago

sir please give me a image of gear box

vahid_you2004 (author)  darshv5 months ago
Sir, I just came across this project, and its the best line follower i have seen.
I tried to make it but having some doubts. Can you tell me where to connect the motor terminals, the bottom board terminals or back board terminals? or both?
having trouble . Please help
vahid_you2004 (author)  aneeshprasobhan1 year ago

Both boards.

I have the same doubts. Should the capacitor be in parallel with the motor? Can I ask why?

vahid_you2004 (author)  amshieee5 months ago

Yes, this is for motor noise reduction.

Can you pls post the full detailed schematic diagram. Showing the connections of all the ICs used.
You can find the only diagram that I have in older comments.
Thank you sir. I just want to ask if there is no really supply on the vdd and vss of 16f877a

ic won't work without supply, so there is a 5v supply.

amshieee6 months ago

If I use CNY70, is there something that I need to change, for example, the circuit connection and/or the source program???

vahid_you2004 (author)  amshieee6 months ago
You must compare the datasheet of two components.
imronmd76 months ago

sir plz i want line follower program code for arduino atmega8 by using tcrt 5000 analog array sensors which cotain 5 sensors and also for 7 segment timer display which start time when robot while on and stop time when robot while off

imronmd7 imronmd76 months ago

send code to imronmd7@gmail.com

it's sir plz plz help me

code for this arena to find short path complete the trak

close event-L1.png
amshieee6 months ago

Good day Sir! May I clear, are the resistors 1/4 or 1/2 watt? Are those motors DC? Can we also use servo motors? =)

vahid_you2004 (author)  amshieee6 months ago
1/4. DC. Yes, but you must make them rotate 360°.
amshieee6 months ago

Can I use CNY70 instead of TCRT5000?

vahid_you2004 (author)  amshieee6 months ago
You can use any similar components.


Can you send me the schematic diagram.

Please mail to ksaravanakrishnan@gmail.com

You can find it in below comments.
avenidodaryl6 months ago

can i use PIC16f887A as substitute?

vahid_you2004 (author)  avenidodaryl6 months ago
Yes, but you must compiler code again for your PIC
gursimran singhs made it!7 months ago

i have made line follower robot using ardiuno UNO , robodiuno motor shield , two ir sensor and two gear motors . sir plz send me the circuit diagram . i have code but

ven.reak8 months ago

i want to buy it. How much?

vahid_you2004 (author)  ven.reak8 months ago
Come on, it is a DIY project, try to make it yourself.
dody.mandy5129 months ago

sir ,, can u send me the code for this arena !! I wanna help plz !!
I use 4 IR sensors and DC geared motor

send me on dedoo.shanshan@yahoo.com

vahid_you2004 (author)  dody.mandy5129 months ago
You can find the program for any path in the instruct able.
tk.joe.99 months ago

sir , sorry to bother you , can you send the circuit diagram about this robot for me through email? it will be a great help. thanks in advance. j0etk@hotmail.com

conorloveskat10 months ago

i want code for this arena ... im using ATmega 8 with 2 DC geared motors !!! and im using AVR STUDIO 4 as a complier an im writing code in simple c !!! please help me

vahid_you2004 (author)  conorloveskat10 months ago
The program code is so simple that you can change it for your microcontroller easily.
usama200010 months ago

Can you please give me the Proteus or any other software file

vahid_you2004 (author)  usama200010 months ago

I only have the files that are attached to step 3.

usama200011 months ago

The PCB tracks are too small and when i connect them to eatch other the copper strip off the board second the battery holder 6v and -6v ends are used and the other ends are not used plzzz answer me quick

vahid_you2004 (author)  usama200011 months ago
some of the copper parts beside battery holder are just for fastening the battery holder and doe not connected to electrical circuit.
tave031 year ago

¿Cómo puedo representar este robot en un diagrama de flujo?

1-40 of 154Next »