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

Step 3: 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

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

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

Download the robot program (Code.hex) and program the PIC16F84A IC.

Step 8: 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.
Hi may I ask if can I use 5 channel line tracker sensor with h-bridge and aceduino (arduino clone)? I have project and need to do the line follower.
Yes, It's a new project, with new sensor arrangement, new processor, ...
How can I do that? I mean 3channel line tracker sensor?
<p>Just add two more sensors ans connect them to the microcontroller using a circuit i used for each sensor, then add them to your program and change the code to use them.</p>
<p>good day sir,<br><br>can i replaced pic 16f877a instead of pic16f84a because there is no available stock in our market...</p><p>thank you sir</p>
<p>yes, you can use any microcontroller but you must change the PCB and you need a little changes in the program.</p>
<p>hi sir, just wanna ask if the motor drive that you used which is L298 can be replace with L293D? and does all the LED's have a specific function?</p>
<p>Yes, why not?</p>
<p>yes, you can. front led is the state indicator and the 4 back leds are motors indictors. you can omit motors leds.</p>
hi sir instead of using pcb can i mount all the components in breadboard just in case there is something i want to change in the circuit?<br>
sir i don't see the motor driver in the circuit? do you have a complete circuit diagram sir with the motor driver included? :)
<p>No, I have not. See the below comment, you can find useful diagrams there.</p>
<p>sir can i replace the motor driver L298 with L293D?</p>
Sir, where is the LS port the bottom board? I cant find it in the pdf that you have given' thanks
Beside L Sensor
<p>thanks sir' can I use 1/2W resistors instead of 1/4W? </p>
<p>sir, can you please show the actual picture on how you solder the rear part of the car? the one with the motor driver part. And also the connections of the batteries and the motors cause I can't figure it out.. thanks!</p>
<p>I just have the photos that exists here, solder terminals with the same name together. The circuit diagram of L298 motor driver (you can find it in above comments) can help you a lot.</p>
<p>Sir, does the motors will start when I placed the battery supply on the circuit board even though there is no PIC? I'm curious if the circuit that I built is already functioning even there is no program yet. thanks'</p>
<p>no, the PIC activates the motors.</p>
<p>sir what is the used of 4 variable resistors? can you please send the schematics of the front board? is the led on the comparator will light when I ON the circuit? thanks'</p>
<p>please read the steps 8, 9 and 10.</p>
<p>is your 4 batteries connected in series?</p>
<p>yes and just end points used for powering, midpoints a just for fastening battery holder to the pcb. you can ignore them.</p>
<p>sir, the motors aren't working.. what could be the problem?</p>
<p>read the below comment, they could help you.</p>
<p>Sir' is it okay to use a 9V battery? if yes, how to connect it? thanks</p>
<p>yes, (+) --&gt; +3V, (-) --&gt; -3V</p>
<p>sir, is it okay to use a 12Mhz oscillator instead of 4Mhz? 4Mhz is not available in our market...</p>
<p>yes, you can</p>
<p>I have fully assembled the entire model...PIC also got programmed after a lot of hurdles...But now when i turn on my robot, the custom motion LEDs light up and can be modified through push button switches, but I am not getting any feedback from the motors....Please suggest the specific component or part which should be debugged. BTW, I have checked all the connections of L298, the seem to be fine. Is there any other part related to motor movement?</p>
<p>If the LEDs light up it means the PIC works check L298 connections, test it by applying 5V to its inputs.</p>
<p>picture with white background</p>
<p>i checked my l298 wirings according to the diagram given by you. thanks for that....all my wirings were fine..and like you said, I tried connecting VCC to the logic inputs but nothing happened. What could this mean? Also, please find some time to chat with me regarding this model debugging, I have spent a lot of time debugging this till now and so far everything seems fine, however I would like you to assist me in this. Please chat with me on Google Chat. My email id- utkarsh.naveen@gmail.com</p>
<p>i want to add that whenever I short VCC to the logic input, the respective LED starts glowing which is leading to the conclusion that L298 might be working, but somehow my motors aren't powering up(MAYBE). Please give your opinion on this</p>
<p>when you connect vcc to the l298 inputs leds glowing because the leds are connected the the l298 inputs and pic outputs. pic can turn leds on or off so the pic program works correctrly and connectiong from pic to leds are correct, leds glow when you connect vcc to l298 inputs so connection for l298 to leds are ok and so connection from pic to l298 is ok too. when you connect vcc to l298 inputs and motors are not working it means that your l298 does not power the motors try applying power to your motors and test them, check output power of you l298 when applying vcc to its inputs by a voltmeter. send me the photos of you boards.</p>
<p>i tried measuring the voltage of motors, it was 0.0V, both normal and high input conditions. I think this means that something is faulty in L298 part. A note for the pictures. I have connected all the boards using LED legs and female sockets. Red wire going is the VCC connection of top board with the rear board. </p>
<p>would you test this for me.. in my board.. The two terminals of motor have 0 ohm resistance in between them... Is that the same in your model.</p>
<p>No, It should not be zero.</p>
<p>I have found out what was causing the 0 resistance! It was the motor, which I think is fine. Whenever I disconnect the motors, the inter terminal resistance become infinite. Hence I think that in this aspect too, my &quot;L298&quot; is behaving as it should. But still, it really worries me how after all this testing success, my robot still fails to move. Also I want to tell you that I haven't used &quot;TCRT5000&quot;, instead I have used a pair of IR receivers with the same polarity as defined in the silkscreen. I don't think it is the culprit. How do you think I should proceed. Also, the National Model Selection in my city are going to be coming soon. I want to show this model for the selection and I also need a week to modify this. So as I had requested you earlier, please chat with me through any other MORE CONVENIENT and REAL TIME means. Instructable's chatting system is very slow. I need to finish this ASAP to better my chances of modifying this properly. Please reply to me ASAP. I really want to get selected!</p>
<p>I can't see anything wrong, everything that can be understood from the photos are fine. I advice you to separate back part from the others and try to test it using above L298 circuit diagram and try to run your motors manually. The problem may be solved.</p>
<p>ok thanks for helping me out to this extent ....really thankful.....now i think my main aim will be to debug the 0 resistance problem of l298. i think it may be hindering the running of motors..if that doesnt work. then i'll just use a new l298!</p>
<p>i want to make the line follower track the line backwards based on a momentary input switch...is it possible....??</p>
This robot follows any line (black or white) no switch needed. BTW you can change the PIC code to have a customized robot, you can program anything you want. Without the code it is just 4 sensors, 2 motors. The code defines the relation of sensors to motors action.
<p>no, what i meant to ask was that i want to make it start retracing its path backwards when I TAP a momentary/switch..</p>
<p>As I mntioned you must edit the progrm.</p>
<p>please suggest a good ide for pic programming....i think i should learn this programming....It is similar to java ..no???</p>
<p>HiTech C, mikroC for PIC, PIC Basic Pro, ..., Just search the internet for best. C is more similar to java.</p>
<p>ok i will do it....thank you</p>

About This Instructable



Bio: I'm a mechanical engineer, and I like computer programming, mechanics, electronics and specially the robotics.
More by vahidyou:Serial Port over WiFi Cheap Logic Analyzer Cheap STK500 AVR programmer for Atmel Studio 
Add instructable to: