Basic Bug


Title Picture For Basic Bug Tutorial 

Basic Bug

 Build a small 4 legged walking "bug" style robot using just 2 Servos


Welcome To my tutorial on how to build a basic bug style robot.

This style of robot is quite popular with BEAM builders, they are generally only used as a proof of concept type build with the parts being scavenged for other bots after a short time.

The reason that I decided to build one is because I want a robot base that would make sensor such as encoding wheels unusable and force myself to find some other way of accurate mapping. Why? because if you use encoders, it only takes somebody to nudge the robot or for a wheel to slip for the mapping to become unstable.

I could have just built or used my existing differential drive project, but i thought this style would be much more fun - and im planning on giving them to my nephews as birthday presents next year.


The first part of this tutorial will be a guide to building the base, making the electronics and then programming a basic software library which can be re - used by different programs.


There will then be a series of upgrades starting with the usual photophile/ photovore upgrade, bump sensor upgrades, radio control, and finally developing a mapping system.

Build The Basic Robot

Build The Basic Bug

Parts List


Before we get stuck into the tutorial, it would be handy to know what you are going to need for the basic bug base.

 Below is a table of materials and parts you will be needing with an approximate price and then there will be another list of tools you will be likely to need.



Electronics Parts

Below is a list of the electronics I used, It would be possible to use the circuit board from the $50 robot meaning that you would only need the servo's from the list (if you plan on building this robot and use the below parts, you will need some way to program the pic mcu. A pic programmer can cost an extra $25 - $200, although I plan on writing a "build your own PIC programmer tutorial soon")

 Part Quantity Price
 hitec hs 311 standard servo (UNMODIFIED)$8.99 each  
 36 pin male breakaway headers2$2.99 each 
 16v 100 uf electrolytic capactor (radial)$1.84 for 10 
 10kohm resistor (1/4watt)$0.49 for 5 
 10 mhz crystal1$0.40 each
 33pf ceramic disc (radial) capacitor2$1.89 for 10
 40 pin Open Frame dip socket (0.1" lead pitch,0.6" (15.24mm) Row Spacing)1$0.48 each
 pic18f452 i/p mcu 40 pin dip 16kx16 prog mem, 1.5kx8 ram, 256x8 eeprom1$10.25 each
 0.1" spacing, 2 way header pin jumper1$0.50 for 10 
 5v linear voltage regulator (1 amp, TO-220 case)1$0.49 each
 Grid style pcb development board or eurocard (0.1"/2.54mm hole spacing)1$1.79 - $6.50
 Some spare wire some ~$2
 Total  ~$45.00


Building Materials

Below Is the list of building materials you will need to gather, the flat plastic can be any hard plastic sheeting such as pvc. The Polymorph granules are a type of plastic that you drop into hot water where it becomes mouldable like modelling dough, once it cools down it hardens into whatever shape you mould it which is then machinable. It can be re - used simply by putting it back into hot water.

 Part QuantityPrice 
 some form of flat plastic (i used plexi glass) 1 sqr foot ~$2.50
 Wire Coat Hanger (or long wire rods) 2 ~$0.50
 Some Type Of Mouldable Plastic (I used Polymorph) 100g ~$5
 Small Selection of Nuts and Bolts  ~$2.50
 total  ~$10.50


You Will Also Require The Following List Of Tools / Products:

-Modelling Knife

-Coping Saw (Or Electric Jigsaw)

-Metal Ruler

-Needle Nose Pliers

-Soldering Iron


-Acetone or cellulose Based Paint Thinners / SuperGlue / Acetone (to stick the plastic sheeting together)

-small cheap artists paint prush

-small phillips screw driver

-Drill with a selection of drill bits

-PIC programmer

If your computer has a serial port, it is also recommended to get this RS-232 Shifter Board

1. Mechanics / Construction


This section is dedicated to building the chassis, forming the legs, and attatching the servos.

 Build The Chassis  

The main chassis is made out of a sheet of flat plastic material (I used plexi glas), The design that I used is in the pictures below. Simply draw the design onto your flat plastic, I scored the design into it with a modelling knife.

Next you will need to cut the pieces out, you could use a saw such as a coping saw, or use an electric jigsaw or something.
Note: You will need two of the connector pieces. 
Try to see if your servo's slide into the gaps in the ends of the body pieces, they dont need to fit all of the way in lengthways. 
Next you will need to add some holes to bolt your servos onto the body, line your servos up like this:
And then mark out and drill the holes. 
 You will then need to glue the various body segments together. They will need to fit together like this: 
If you are using acetone or the paint thinners method, these work by melting the plastic slightly on contact, the acetone/thinners evaporates quickly thereby allowing the plastic to set again. Liberally apply the thinners to both of the surfaces to be joined then press together and hold firmly for about two minutes. Leave to set properly without any tension for a further 5 to 10 minutes.
Making The Legs
First of all center the servos, you can do this electronically if you know how, but i find that just manually centering works well enough.
Your servos should have come with a "horn" attatched. Twist the horn all of the way to the left, then all of the way to the right. The turn it to the position between the two extremes.
Once you have found the approximate center, remove the servo horns by unscrewing the little black screw in the center. While you are doing this you should want to keep hold of the horn and the servo to stop it turning out of position.
Now we need to make the leg mounts. We will be using the round servo horn and the cross shaped servo horn.  
Place the cross servo horn onto the round servo horn, make some pilot holes to attatch them, if you look at the cross horn you will notice that there are holes already on it, you will need to take one of the pointy screws that came with the servo and screw through the secod hole in from the outer edge of the cross servo horn arm, screw all of the way through to the round hown underneath. Do this on three of the arms. 
Next, unscrew the two horns again so they are seperate. drive the screws back halfway through the round servo horn. 
Take a length of rigid metal wire such as a coat hanger(about 30cm / 12") and fold it in half fashion them like this to fit onto your servo horn mount:
Put the servo horn mounting screw through the middle hole, then place the cross shaped servo horn over the top and screw together.  
 You can now attach the servo mount back onto the servo. 
 Repeat this process for the other servo 
 Next Shape The legs to look similar to this 
 The legs will catch on carpet, and slip on smooth surfaces, so you will need to coat them with something, I used the Polymorph granules, but only coated them about halfway up so I can easily alter the shape and position of the legs later if I need to. You might also want to put some hot glue onto the very bottom of the legs to make them slightly tackier 
 You might be able to just push some polystyrene onto the legs 
 Bolt the servs onto your robot base like this if you havent done so already
 That is the end of the mechanics / construction part, You may want to add some extra holes onto the back part of the robot in order to mount your circuit board, I think I made the dimension Right to be able to fit the prototyping board from the $50 dollar robot onto the back base, Just mark up your screw holes ready. 

2. Electronics

 This page is solely dedicated to making the electronics to build and run your basic bug robot. 
 If you already have the controller board for the $50 robot built, then you can just use that in stead of completing this section. 
 Luckily the electronics are quite simple, its basically just an interface to break into the mcu to allow us to connect servos and sensors to it easily with a built in power bus system. Lets get stuck in and see the easy to understand schematic: 
 Description / About the schematic 
 Parts Breakdown 

 This is the power input area. The two pins on the left are where you connect the battery or power source, red to + black to -.

The black/grey part at the top is the 5v regulator, provided that the input source on pin1 is greater than 6 - 7v it will produce an even +5v output on pin 3. The middle pin is for the common ground. So input goes to pin 1(+) and pin 2(-). The output is pin3(+5v) and pin 2(gnd).

The blue cans are the electrolytic capacitors, the one on the left goes between input voltage and ground, this is there to provide a backup of power incase your battery need help. The one on the right helps the voltage regulator by smoothing the signal, The voltage regulator gets hot when it is used, because your circuit will be drawing different amounts of amperage at different times, the voltage regulator has to work harder shifting between the powers and getting even hotter, The right capacitor goes between the output voltage and ground It provides additional power in case of excessive current draw, and also helps the voltage regulator by handling a lot of the current changes and keeping the regulator cool.

Note: I used this setup for 2 hours with the servos and circuit running through the voltage regulator, and it didnt reach above 50 degrees C. 


 This is the PIC18f452 mcu. When soldering the board, dont solder the mcu in. You should solder in the DIP socket that was on the electronics list, the PIC mcu will then slot into that dip socket later, so you dont damage it when soldering, and it is removable for other projects and programming if you dont have an in circuit programmer.

Notice the pins are numbered, The picture below show what the pins actually are.


 This is the PORTA bus, the bottom set of pins are connected individually to the porta pins on the pic18f452. This port has 5 a/d converter pins on it so we can use it for sensor input later.

The middle set of pins are all connected together, and then connected to +5v to make part of the power bus.

The Top set of pins are all connected together, and then connected to GND to make the other part of the power bus.

When soldering these, the pins all want to be next to each other, so the gnd pins go in, then the +5v pins go in the holes directly next to them. You should end up with 3 rows of 6.


 This is the port D bus. PortD is a general i/o port, there are no special features attatched to it apart from its ability to be an 8 bit paralel output which we probably wont be using on a robot.

This port is ideal for controlling devices such as servos.

The bottom set of pins are connected individually to the portD pins on the pic18f452(port d is scattered about 3 different location on the pic).

The middle set of pins are all soldered together and then connected to +5v.

The top set of pins are all soldered together and then connected to GND.

As with the above these sets of pins want to be placed right up next to each other to make 3 rows of 8 pins.


 This is the serial interface, The pins are arranged to connect directly to the rs-232 shifter board from sparkfun electronics.

The right pin is +5v

The 2nd in from the right is GND

The 2nd in from the left goes to the TX pin on the pic18f452

The left pin goes to the RX pin on the pic18f452


 This is the JDM ICSP programming header, compatable with a JDM style programmer.

The pin n the right is connected directly to the MCLR pin on the pic18f452.

The 2nd pin from the right is connected to +5v.

The middle pin is connected to GND

The 2nd pin from the left is connected to PGC (programming clock) on the 18f452

The left pin is connected to PGD (programming data)on the 18f452


 This is the reset header, the left pin is connected to the MCLR of the 18f452

The right pin is connected to a resistor, which is then connected to +5v.

When you h333ave your pic programmed and runnin, use a pin jumper to connect the 2 pins together, to do a soft reset on you program, remove the jumper and put it back in.

When using a jdm style programmer, you will need to remove the jumper when programming. The mclr pin must be brought to around 12/13 v to enter programming mode and so we need to isolate this from the main circuit by removing the jumper.


 Finally, this is the oscillator crystal set up. The silver can is the oscillator, one leg wants to connect to the OSC1 pin on the 18f452, the other leg to OSC2.

Each leg should also be connected to a small ceramic capacitor usually between 22 and 35 pf, I am using 33pf capacitors (the datasheet says 30pf)and it works just fine. The capacitors want to be connected between each oscillator leg, and also to GND.

 Here is my completed board, notice that I decided to cut my board and shape it to fit over most of the back section and to go around the servo. 
 Unfortunately I didnt plan it very well meaning that there are connecting wires everywhere. I did leave enough space to connect up the other ports on the 18f452 later if i ever need to, There are another 3 a/d converter ports on porte and another 14 i/o ports which most have other possible functions such as i2c control, and interrupt pins 
 Unfortunately I didnt add in any way of testing the circuit to see if it works, you could use a multimeter to make sure that there are no shorts anywhere. Remember do not put the Pic18f452 into the socket until you are completely sure that the circuit is correct. An easy tester for this would be just an led with a 330ohm resistor connected to the cathode leg, then plug in the circuit to a battery pack or a power pack and connect the led annode to one of the +5v power bus lines and the free resistor leg to one of the Gnd power bus line. If the led lights up, your circuit is fine from the power front whcih is good news. 

3. Programming (PIC18F452)

 This section is dedictated to building a basic set of functions. The Functions will be created in a header file that can be used by different programs. The reason that we are going to use a header file, is that most of the "messy" work will be stored there instead of cluttering up your main program, it also gives us a universal library which can be used by any c program that you create for this robot. 

 Before we go any further, you are going to need to download microchip c18 utility (student edition is fine) and the microchip MPLAB ide. Both of these can be downloaded for free from

You will need to install both of these, following the on screen instructions. I think to avoid confusion, its best to instal MPLAB first and then the C18.

 The next step is to use the project wizard to create a new project. You should follow the users guide (pdf) to learn how to make sure that the c18 compiler has integrated properly and also see how to add the linker file to your project. 



bb gun tank

Hello! I am currenty trying to build a robotic bb gun tank.  I have only built the gun part of the tank and I got the two motors that will pull back the barrel and fire the bb gun.  I am only 9 years old and I have never built a robot from sratch yet. I have built robots with lego nxt and in my school, but never with anything else.  If you are ever buying motors, don't ever buy a motor with 1-3 r.p.m. unless you need a very, very, slow motor because I made that mistake when I bought my motors.  Now I have to lower the extra torque to make the r.p.m. go higher using gears.  I will update this page as soon as I can


I don't have much supplys so instead of using gears, I am going to subsitute the gears with rubber wheels for friction and making the speed faster.