Let's Make Robots!

War Pig - Line Follower Robot

Line follower

I'm proud to show you my first robot.
Its name is "War Pig" and it's a line follower.

I'll give you some technical specifications about the project.

Let's start from the electronic schematic.

The core of the circuit is the PIC18F4331. I know it's definitely over sized for the project, but since it came as a free sample, I didn't loose time to find a cheaper one.

Ground color is detected through two photoresistor. The signal is read in the middle of the serie between a 2-20k photoresistor and a 10k resistor: with this configuration the difference of voltage read from the adc is quite high, and can be easily treated like a digital input.

Motors are actioned by the L293D driver. PWM signals move the enable pins and set the velocity of the wheels through a simple algorithm.

Power supply is made with a 9V battery regulated by a standard 7805 voltage regulator. This is the worst part of the project, since I used the same power supply for the microcontroller and the project. I had some difficulties in avoiding the PIC to restart every time a motor was actioned and I finally did it putting a lot of decoupling capacitors near to the microcontroller.

I put the ICSP connector in the back in order to be able to program the robot without removing the PIC from the socket. Very useful idea.

White LEDS allow the robot to "see" the line in a dark room.

Structure is made with Plexiglas and long screws. It's light and simple but it took me a long time to make the several holes in it.

Here are some pictures:




Bill of Materials:
PIC18F4331 Microcontroller – FREESAMPLE
Resistors & Capacitors – €5 (approx.)
Sockets, Connectors & Wires - €3 (approx.)
2 * White Led - €0.80 ea.
2* 2-20k Photoresistors - €0.80 ea.
L293D - €2.5
MC7805 – 1€
9V rechargable battery - €4
2 * Wheels - €3 both
2 * DC Motors - €14 both
Ballcaster - €3.5
Plexiglas - €2.50
Screws - €0.50

Bill of Time:
Construction – 6 hours
Soldering – 6 hours
Programming – 4 hours
Prototyping the circuit on the breadboard – 10 hours

Personal comments:

+ it works
+ it's cheap
+ photodetectors work well even if not well shielded

- bad battery last
- bad power management
- dc motors are not very precise
- quite slow

Please, please post your comments here or on youtube and feel free to ask for any further information about the robot.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hwy man you got a nice line follower there........... but can you help me with these:

what exactly we need to build this robot

and the algorithm of the picaxe.. please


Bill of Materials: Tells you what you need to make the robot.

As far as an algorithm go straight. If one of the two sensors detects a black line turn left or right slightly depending on which sensor was detecting the line. Line detectors have a pretty easy algorithm. Now if you want all of the code thats a different story. If you haven't made a robot yet I suggest the START HERE link at the top of the page. That project is laid out in detail so you can duplicate it easily.


use the bill of materials and the schematic in order to complete the circuit.

algorithm is really that simple! you can do better if you are fond of automation and numeric control. i am not.


by the way... it's nice to found interest in my work after something like 9 months! thank you!

you're welcome.. you're robot is really nice....... and thanks for the information you gave.......


but should I use the same picaxe you used, and the same sensor you used, or another one??

but you didn't mention the type of sensors did you use?

sensors used are photoresistors.

there is no picaxe in it. I used the PIC18F4331 (4431 is good too) microcontroller from microchip, as you can see both in the schematic and in the bill of materials.


I like your design and I am thinking about building one for  my college project but I have never built one before.

I am in the process of writing an evaluation matrix and would like to know how difficult you found it on a scale of 1-5.

Thank you.

Hello, I love it, plus the Black Sabbath song WarPigs, i'm a big fan of them, absolutley cool bot, i want to build my self a one, to join the war pigs army, can i ask for the code and the schematic please :) ? 

the schematic is not working please upload it sir ,,, and what about the code