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.
<p>Hi .help me plz im in a compete </p><p>0911 462 45 22</p>
hey im newbie in here,how can i upload the code to PIC16F84A ,what tool must i have to upload the code ? ,please i need this for my school project
Use any PIC programmer. https://www.google.com/?ion=1&amp;espv=2#q=pic%20programmer
I have a question.<br>Can i make it using PIC16F877A??<br>Is there any code to change?
<p>Yes. You can use any PIC but you need a few modifictions in PCB and code depending on the pins of PIC you use in your project.</p>
<p>another question sir.</p><p>when i choose geared motor set,</p><p>i can't find 60rpm 6v geared motor.</p><p>then can i use another geared motor like</p><p>200rpm???</p><p>less than 60rpm is recommended or more is no problem?</p>
<p>It is a DIY project, so you can make any changes you need. The motor speed depends on your robot size and its wheels diameter. Test motors to find your ideal speed.</p>
<p>Can you tell me the role of capacitors..?? and how their values are found..??</p>
<p>C1 and C2 are for microprocessor oscillator, C3 are for voltage stabilization, C4 and C5 are for motors noise reduction. All of these are basic electronic blocks can be found in datasheets and atricles.</p>
<p>just one more thing... what does &quot;&lt;&gt;&quot; stands in the .bas file.</p>
<p>It is like != in C and means not equal, &quot;if a&lt;&gt;b&quot; means &quot;if a not equals b&quot;.</p>
<p>Can u help me?? sent me a full circuit about this project please..</p><p>Sent complete circuit diagram in here or just email me at sk94_epul@hotmail.com</p><p>Please I realy need it ASAP</p>
Please read step 3, specially the last line.
<p>Hi your project is very good and I want to make this robot, but in the proteus schematic, there is no complete circuit I mean there is no ic324 mentioned in there and there is no motor driver shown in that circuit so please send complete circuit to my email &quot;maheshjshetty@gmail.com&quot;</p>
<p>sorry but can you send me the pic program in a other kind of format because i cannot open the program (Code.hex) </p><p> -thank you so much -</p>
<p>Download &quot;Code.zip&quot; from step 7, you can see 4 files in the zip. The .hex file is the compiled file you must program to PIC. The program source code that is written by PicBasic PRO is the file with .bas extension, you can open it with any text editor software like notepad.</p>
<p>Could you please tell me what are those 1N4148 Diodes used for? Thanks.</p>
<p>I see diodes on your real car are not 1N4148, please tell me which is the right one, thank you, sir</p>
I used 1N4007, but 1N4148 is better, they are for back EMF damping (for more info refer to L298 datasheet).
<p>Nice build! I always wondering, where can I get that kind of skinny wheel?</p>
thanks, you can find them in toys.<br>
<p>Other replacement for 10k potentiometers? <br>Because I think the motor state of my work is not really that accurate in terms of turning left or right. like if it's suppose to go right the left motor is in stop mode. What can probably be the cause? thanks. </p>
no need to change potentiometers, when to robot is going to turn left the left motor stops or run reverse depending on the turn. there may be some problems with your sensors, comparator ic, pcb make, ...<br>you can make any changes to program source code and recompile it if needed or test your sensors and motors. it wrote using PicBasic PRO. maybe you soldered left motor wires to the right motor on pcb,
<p>how its work on white line</p>
It is exactly the same as black line. No changes needed.
<p>I want schematic....I tried but I m unable to load the previous comments. I'll be grateful.thanks </p>
<p>As mentioned at step 3 I have only a symbolic diagram of the robot that you can find it there. </p>
<p>i made a line follower robot but i dont know the conf of IR sensors i used bascom avr 8</p>
<p>dear sir please me give a market price of following component</p><p>1)A 4 AA battery holder<strong>(with image)</strong></p><p>2)PIC16F84A Microcontroller + Socket<strong>(with image)</strong></p><p>3)LM324 Comparator(<strong>with image)</strong></p><p>4)L298 Motor Driver + Aluminum Radiator(<strong>with image)</strong></p><p>5)4MHz Crysta<strong>l(with image)</strong></p><p>6)TCRT5000 Infrared Sensors<strong>(with image)</strong></p><p>7)60rpm MiniMotors with Gearbox (6V)</p>
<p>They are all typical electronic components you can find in any electronic components shop.</p>
<p>thanks for giving my first question's answer !!!!!!!!!!!!!!!!!</p>
<p>sir please give me a image of gear box</p>
Sir, I just came across this project, and its the best line follower i have seen.<br> I tried to make it but having some doubts. <strong>Can you tell me&nbsp;</strong><strong>where to connect the motor terminals, the bottom board terminals or back board terminals? or both?<br> having trouble . Please help</strong>
<p>Both boards.</p>
<p>I have the same doubts. Should the capacitor be in parallel with the motor? Can I ask why?</p>
<p>Yes, this is for motor noise reduction.</p>
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
<p>ic won't work without supply, so there is a 5v supply.</p>
<p>If I use CNY70, is there something that I need to change, for example, the circuit connection and/or the source program???</p>
You must compare the datasheet of two components.
<p>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 </p>
<p>send code to imronmd7@gmail.com </p><p>it's sir plz plz help me </p><p>code for this arena to find short path complete the trak</p>
<p>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? =)</p>
1/4. DC. Yes, but you must make them rotate 360&deg;.
<p>Can I use CNY70 instead of TCRT5000?</p>
You can use any similar components.

About This Instructable



Bio: I'm a mechanical engineer, and I like computer programming, mechanics, electronics and specially the robotics.
More by vahid_you2004:Cheap Logic AnalyzerCheap STK500 AVR programmer for Atmel StudioUSB to TTL UART Converter
Add instructable to: