loading

Your first real robot the easy way, learn all the basics while at it :)

Featured
Picture of Your first real robot the easy way, learn all the basics while at it :)
This tutorial is the easiest way in the world to give you a fast start into building robots.

And so, it is very easy!


This is an updated version, the original can be found here: The original instructions

Welcome :)

Everything here is so easy, that after you have gone through it, you can make a robot in a couple of hours. Why cant you do that now?

Because there are so many little things you need to know. This is an attempt to let you know excactly all these little things, and nothing more. Fast, and based on 2 years of experience of what people need to know to get started. If you hurry, you can run through this, and be robot builder in a couple of hours. But expect to use a good weekend - Learning takes time - even though it is very easy, it just takes some time, all the little things to get to know :)

There are other "How to get started building robots" out there. This one is focusing on getting you around everything extremely fast. You need no knowledge of .. anything. And you will learn everything.. well, the basics of everything ;)

All images in high-res here.


(Sorry for the music, it was an option in Youtube to add it - I did not in the next one ;)



 



 
Remove these adsRemove these ads by Signing Up

Step 1: Materials needed

Picture of Materials needed
It used to be a hassle to buy the materials, because not one single webshop was carrying everthing needed, and you had to buy from several shops.

Good news is that LMR have started a cooperation with Solarbotics, so you can buy a complete bundle with everything needed.

All info on how to buy this bundle on http://letsmakerobots.com/start

No matter from where you get it, the following is what you will need
 

Step 2: 1 PICAXE-28 Project Board

Picture of 1 PICAXE-28 Project Board
The 28 pin project board is like a game of Mario Bros; Fun and full of extras and hidden features, making you want to play over and again. It is an exremely good board to get you started, and it can be used for a fantacillion different projects, don't get me started :)

Step 3:

Picture of

Many times the boards that you buy just have wholes in them, and that makes it hard to plug something in / on. One way to overcome this, is to solder wires into the holes. Another is to add these pins, so you can plug on wires, like with the servo and female headers shown below. "Why don't they just put pins in all the holes from the factory", you may ask. Well, I dont know. Maybe to give us the option. It is also possible to solder female headers onto the board, perhaps this is why.

You get these in long rows, and simply break them apart with your fingers.

Step 4: 3 Shorting Blocks, Top Closed

Picture of 3 Shorting Blocks, Top Closed

Put these over 2 pins next to each other, and there is a connection between them!

Step 5: 5-10 Female-Female Header Jumper cables

Picture of 5-10 Female-Female Header Jumper cables
Yes. These are nice. When I started this hobby a couple of years ago, these where really hard to get. Now they are everywhere, and that is really good. Most things in this new robot-hobby of yours have pins (or you solder some in ;) - and by using these wires / cables, you can make quick connections without soldering. Nice!

Step 6: 1 USB PICAXE Programming Cable

Picture of 1 USB PICAXE Programming Cable
You write your robots programs on your computer. Plug this cable into the robot, and transfer the program. Unplug, and the robot runs the program by itself.

Step 7: 1 PICAXE-28X1 IC

Picture of 1 PICAXE-28X1 IC
This chip is a Microprocessor. That is often explained as "A computer in a chip". It can be placed in the board described above, whereafter it can be programmed from your computer via the cable above.

Your program can tell it to "listen for inputs", "think about them", perhaps make some calculations or look in some datas, and make outputs to something like the motor driver below.

It is chosen here, because it is quite strong, yet very easy to program, as you will see below.

Step 8: 1 L293D Motor Driver

Picture of 1 L293D Motor Driver

I will describe this later, when we install it below :)

Step 9: 1 DIL 330 x 8 resistor array

Picture of 1 DIL 330 x 8 resistor array

The Yellow chip! It is very dull, is just a row of little resistors. You will be using it to set your board up for servos.

Step 10: 1 Standard servo

Picture of 1 Standard servo

A Servo is a cornerstone in most robotic appliances. To put it short it is a little box with wires to it, and a shaft that can turn some 200 degrees, from side to side.

The microcontroller can decide to where the shaft should turn, and stay there. Like go to "3 o'clock". That is it pretty handy; You can program something to physically move to a certain position. Next thing (after this project) could be to let one servo lift another servo. You would then have what is refered to as 2 DOF ("Degrees of Freedom"). But let's start with one ;)

You may wonder why my servo has that white pin, where yours might have a flat disc, a cross, or something. It does not matter, servos comes with all kinds of "servo horns". We just need something there, that we can glue the head on to!

Step 11: 1 Sharp Analog Infrared Range Finding System (AERS) with cable

Picture of 1 Sharp Analog Infrared Range Finding System (AERS) with cable
The one "eye" sends infra red light. The other sees the reflection of this (if there is one), and the unit returns the distance to the object in front of it. It has 3 wires (make sure you get the cable for it, or it can he hard to hook up). You give it power on 2 of the wires, and the third one plugs into the microcontroller, and tells it the distance.

Step 12: Battery Holder

Picture of Battery Holder

1 4 x AA Battery Holder if you are using rechargable batteries, or
1 3 x AA Battery Holder if you are using non-rechargable batteries

(See more below, regarding bateries, and why the difference - Point is that you need as close to 5V as possible, one way or the other, and you can use something completely different in terns of batteries if you want. As long as it is just about 5 Volts.)

Step 13: 2 Geared motors and wheels to fit

Picture of 2 Geared motors and wheels to fit

It is very important that your motors have gears. You want a slow robot; Go for high ratios, like 120:1 or higher, as a slow robot is so much more fun in the beginning, because you can see what it is doing.

Apart from that, there is not much to say. Well, that would be, that there are many ways of moving and steering. This way of only using 2 wheels, is sometimes referred to as "skid steering". And it is worth remarking that if you'd like to add belt tracks later on, the basics are the same ;)
 

Step 14: 1 Roll of double sided foam tape

Picture of 1 Roll of double sided foam tape

Oh yes! If there is something you cannot fix with this tape, it is because you are not using enough! It is a very, very fast way of sticking 2 items together. In fact we will be using it to make this complete robot! Depending on the make, of course, it is also reasonable easy to take apart again.

This kind of sticks, that tape, and a melt glue gun is the backbone for most of my fun with robots :)

Step 15: 1 Heat shrink tube (5 mm approx)

Picture of 1 Heat shrink tube (5 mm approx)

Sometimes you do need to solder 2 wires together. For instance the Sharp IR Range finder; It comes with straight up wires on the plug.

What you do, is cut one of the female cables (above) in 2 parts, solder them together.. but before that, you cut a little piece of this heat shrink tube to slide over the place without insulation.

Then with a lighter, you can quickly heat up the tube, and it shrinks to fit.

That is so much smarter than using tape ;)

Step 16: All of the above materials are included in the LMR bundle.

Also needed..

Step 17: Batteries

Picture of Batteries

Either 3 AA Non rechargable, or 4 AA Rechargable.

This robot needs 5 Volts. Mainly because the Sharp IR, really feels best on 5V, that's what it's made for. Motors and servo would like more, microcontroller could live with 6, but keeping it simple is the core here, so we feed the whole robot with as close to 5V as possible. And rather too little than too much, so we make sure not to fry anything, now that this is your first robot ;)

Now, you may know, that normal batteries provide 1,5V. However, you may not know that rechargable batteries only provide 1,2V!

No matter if you knew that or not, 3 times 1,5V from normal batteries, is 4,5V. If we use 4 times 1,5V we would get 6V, which might be a little scary to use on the Sharp, rated for 5V.

4 times 1,2V from rechargables is 4,8V which is nice and close to 5V. And then it is much cheaper in the long run. So I strongly recomend you to get some rechargables and a charger.

Tip: The best rechargables have the highest mAh, 2500 AA-size is a fine battery.

Step 18: A Soldering iron and solder

Picture of A Soldering iron and solder

Step 19: A lighter and a cutter

Picture of A lighter and a cutter

Lighter for heat shrinking, cutter to.. cut.

Tip: If you want to use the cutter to remove plastic from cables, turn it this way; Imagine that you where sticking the cable right into the cutter from where you are now, into the table it is laying on. That way. And not from the table, and out to where you are. Then gently close around the wire, and pull the plastic off.

Step 20: A computer with an internet connection and a free USB port

Picture of A computer with an internet connection and a free USB port

Can be Mac, Linux or PC. The software needed for this is free.

Step 21: Nice-to-have tools, though not essential:

Picture of Nice-to-have tools, though not essential:

A multimeter (aka measure-thingey), a wire stripper, and a screwdriver.

Step 22: Ready? Let's make a robot :)

Picture of Ready? Let's make a robot :)

First unwrap your board (I am sure you already did that :), and then see that it may have some red stuff underneath. That is just there from when they made it; They insert the components on the upper side, and dip the boards lower side into hot solder.. and areas where they don't want solder to be stuck, they have placed that red stuff. So just take it off :)

Let's look at somewhere where we for sure are going to add some pins.. Yes, the motor-outs.

My finger is pointing at them; The A & B on the board. We will get back to them, but for now, snap off 2 times 2 pins, and plug them in.

It does not matter if you snap off single pins or anything like that. They are simply little metal rods in plastic. Short side down into board.

 


Step 23: Use some foam tape to hold the pins in place.

Picture of Use some foam tape to hold the pins in place.

Step 24: Turn around the board, and solder..

Picture of Turn around the board, and solder..

Step 25: And now, tatataaaa.. you can plug in any standard female header, where you used to have a hole :)

Picture of And now, tatataaaa.. you can plug in any standard female header, where you used to have a hole :)

Step 26: Solder a pin into analogue port

Picture of Solder a pin into analogue port

Nice, and while you are at it, also solder a pin into analogue port 0, that we are going to use for the Sharp.

Step 27: Solder a pin into output 0

Picture of Solder a pin into output 0

Solder a pin into output 0, and you are done with pin-soldering.

If it was me, I'd just solder pins in all the holes, but you may want to leave that for later. You have soldered all the pins that we need for this project now.

Step 28: Extensions and alternations of wires and cables:

Picture of Extensions and alternations of wires and cables:
Now, this is a little in-between general instruction :)

Connecting 2 wires "The right way" is almost a religion to some. Here is how I do it :)

First, I simply twist together the 2 wires



Step 29: Solder

Picture of Solder

Then I solder them together, cut some off if it is too long, and bend it along the side of one of them.

Step 30: But first; Add tube

Picture of But first; Add tube
However, BEFORE I do this, I make sure that I have cut off a little piece of heat shrinking tube, and placed it over one of the wires.

Then I slide that over..

Step 31: Heat it up

Picture of Heat it up

A lighter quickly heats it up. This makes it shrink, hence the name, and it is a perfect insulation.

I don't think you realize how hard it was to take that picture all by myself :) It had to be in focus on the right spot, you know. And yes, the wire got a little burned :p Good shot though, if I may say so myself.

Just move the flame quickly from one side to the other, and heat up all sides fast :)

From now on, I expect you to just extend wires that are too short, hook up headers on wires if needed, and if you need to connect something to the board, but it has a hole.. you simply add a pin :)

Step 32: Get it togeter! - Fixing up the motors

Picture of Get it togeter! - Fixing up the motors

Mount the wheels on the geared motors. You may have a completely different set than I do here, but as long as it is geared motors that runs fine on a few volts, and some nice wheels, you will be al right.

When you have the wheels on the motors, cut one of the female-to-female wires in halves, take away some of the plasctic from the end of the wire, and solder it on. And do the same for the other motor.

Make sure no solder or wires touches the metal on the motor :)

Some wheels come with optional rubber tyres. It can be a good idea to wait with putting on this rubber, because if the robot is stuck, it can just slide, which is nice when testing and developing.

Step 33: Chips in the board!

Picture of Chips in the board!

The Picaxe 28X1 Microcontroller that you have here, and the board, is a pretty amazing and very powerful little package.

I remember how amazed I was that I could actually make this control everything I could imagine, I hope you will get that sensation at some point as well; Seriously, you can make this thing do all sorts of stuff with all sorts of electronics that you have in your house. Even if you know nothing about anything, and electronics is as strange to you as it is to me.

You can also make it handle your servos, motors, calculations, monitoring distance.. everything a robot needs. And that is what we are going to set it up for now

The microcontroller is the long chip. That is the one you program, and then there are inputs and outputs on the board that it can use.

 

Have a look at this page: 28 pin Project Board (AXE020), Picaxe for dummies

 

Now, I do not expect you to read that page now, because I have promised you that you will get to building the robot as fast as possible :) However, it is important that you read that page at some point, to learn about the board, and the microcontroller. Promise me to get back to that, make a bookmark ;)

Ok, enough talk, insert the long black chip, the microcontroller, make sure to turn it the right way: It has a marking in one end, and so does the socket. They should match.

 

Now, when you bought the board, it should already have a black chip in it, in the slot where I have placed the yellow chip, in the picture below.

Take up the black chip, and as I did, replace it with the yellow one. It has not enough pins, but see picture for what end to leave open.

The yellow chip is sitting between the microcontroller and the topmost row of pins on the picture. That row has, as you will know when you read about the board, your bookmark, remember, the outputs. We are going to hook up the servo to one of these. Servos are sending a lot of electrical noise back on the line. The Yellow chip is a series of 330 Ohm resistors, that will reduce the amount of noise that is sendt back to the microcontroller. It is simply straight lines across, with some resistance between, making the signals traveling both ways a little weaker. So it is there to protect the microcontroller. Frankly, I have never heard of anyone frying a microcontroller because of servo noise, but since manuals tells us to do this, and the board is prepared for it, we might as well.

I have also heard of black versions of this chip. How boring, but none the less, and yes; You can use it, no matter the color, if it has the same functionality.

The black chip that was in it's place, is a so-called Darlington-thingey! If you need more info than that, please read the manuals :) But it is a good chip, if you are not using servos; It is magnifying the signals, so for instance you can hook up a speaker right on it (where we now will be placing a servo) - and using the command "Sound", you can make it beep quite loud, play tunes etc. You have got to try that as well! Just not now ;) Disadvantage of using the microcontroller and this board for everything is that when you want to play with servos, you take out the Darlington, and the fun it provides. But there is more, wait and see!

Last chip is the motor controller, throw that in as well!

When your Microcontroller is placed in your board, it can switch power on/off. You could use that to drive motors. However, motors are "rough", and could fry the Microcontrollers outputs. And another thing is that if the Microcontroller can only turn power on/off, then.. how do you drive backwards?

A motor driver takes care of all this;
This little motor-driver-in-a-chip can drive a pair of small motors (600 mAh each, for the tech interested), without frying the microcontroller. And furthermore; It can make the motors go backwards. Which is handy when facing a wall :)

Your nice board has a place for a motor driver that can take a pair of small motors, and make them drive both forward and reverse.

The board is set up, so the microcontrollers output's 4, 5, 6, and 7 are fed into the motor controller, and out comes 2 fine pars of lines that you can hook a pair of motors on to; The Motor A and Motor B. And you just soldered pins into them, how nice.
 

Tip: New chips in
New and unused chips usually have the two rows of legs a little too wide apart. So gently push down the side of the chip towards a table to correct it, before inserting it into a slot. You will understand me once you try to put a new chip in place in a socket ;)

Tip: Old chips out
It is easy to get chips up from the sockets, by inserting a flat screwdriver below it, push it under, to the far end, and gently push it up.

Fact: Later in your life, you will just want the microcontroller to just be a microcontroller. You then buy extra other boards for something like servo control and motor control. These boards will get their commands from the microcontroller. And then your robot can do everything much more powerful, and at the same time. However, it is pretty amazing what you can make this setup do, as you have it right here! Many, many cool robots and other project use far simpler or just this setup.

 

Step 34: Make the body.. without a body!

Picture of Make the body.. without a body!

In order to keep this as simple as possible, we are just gluing all the parts together, and call that a robot! Yes.

If you prefer, of course you can make it more advanced than this. Only thing to note as such is that we use 2 central wheels, each with one motor. Driving both forward makes the robot drive forward, and if one is going backwards with one forward, it turns on a plate. If one is still, and the other is driving, it is more like "sliding" to one side.

What you can do, is simply to stick on the motors to the battery holder, using the foamy tape. If the batteries are in there, and the wheels are big enough to have them placed below the axle, the whole thing will simply balance on its own. Quite strange, actually, when I think about it :)

Step 35: Mount the servo

Picture of Mount the servo

Some how also make room for the servo in front. Or stick it on to the front of it all.

Step 36: Make sure it can drive

Picture of Make sure it can drive

Most important is that wheels touches ground, and the rest is more or less in balance. It does not matter if it is tipping a litle backwards.

Feel free to make your own design, of course :)

Step 37: A tip regarding batteries

Picture of A tip regarding batteries

Now, as you can see, this time, I use the 4-battery holder. Because that is the biggest one, which makes it easier to stick it all on to it. But...

Step 38: 3 batteries in the place of 4

Picture of 3 batteries in the place of 4

- But if you are using non-rechargables, and only should ue 3 batteries, here is a tip:

Find an old telescopic antenna, from a radio or something.

Cut off a piece (Here is a tip on how to cut it), and insert it instead of one of the batteries. Bingo ;)

Step 39: Hook up he power

Picture of Hook up he power

Next thing is to place the board on the robot, and hook everything up (apart from the Sharp, wait with that).

First: Take out the batteries again (or at least one of them). Just to make sure you don't fry something by accident. We dont have an On/Of on this robot; Batteries in, and it is alive. But we want it dead now, so one battery out! (and not like on next picture, doh!)

Some battery holders have wires (like the one I am using), and some have a clip that fits right onto the clip on the board, as illustrated in the 3 battery holder below. If you have a clip, then hook it up, you are done. If you have wires like me, cut off the clip from the board, and connect black with black and red with red. (and use shorter wires than I did ;)

Step 40: Hook up stuff to the board

Picture of Hook up stuff to the board

Hook up the servo

Your servos wires colors may be different, but the hints are; Brown or Black (Ground) to the outside, red (Volt) in the middle, and yellow or white (Signal) on the inside.

These descriptions may make most sense to you, if you have read about the board, as you promised me to to earlier (link further up). But for now you can just note the colors, and make sure to plug in your servo the right way around :)

Step 41: Mount the board, and hook up the motors

Picture of Mount the board, and hook up the motors

With some (more) foamy tape, stick on the board to the rest of the robot.

Make sure the mini-jack (the metal ring in one end of the board) is placed so it is easy to plug in a cable, because you will be doing that many times! And be careful to make sure that the bottom of the board does not touch any metal ;)

Hook up the motors wires, into the A&B-pins that you soldered on earlier:

One motor's 2 wires goes to A on the board, the other to B. It does not matter which goes to which, we will manage the rest in the programming.

 

Oops, one of my motors wires was too short, so I added little blue extensions from a scrap piece of wire that I found.

Step 42: Clean up the wires

Picture of Clean up the wires

There is a nice little room to stuff in excess lengths of wires :)

Step 43: And voila!

Picture of And voila!

(Yes, I know that your robot still has no face :)

Step 44: Programming

Picture of Programming

We need to turn the servo to center. Of course you could try and do it by hand, and estimate it to be in center, but the smarter way is to let the microcontroller put the servo to center. Because then you can mount "the face", facing forward, right where the microcontroller thinks it should be, when facing forward.

You are going to take a "Time-Out" from this tutorial, because you will need to set up your computer to know there is a programming cable attached, and a piece of programming software must be installed.

I cannot help you much with this, as t is up to which computer you have, and what the folks at the Picaxe website have updated after I wrote this.

However, go to

http://www.rev-ed.co.uk/picaxe/ (or the easier to remember: picaxe.com - that redirects you)

Depending on your OS, you want either the

Free PICAXE Programming Editor or the AXEpad (which i also free, it is just not in the name ;)

Download and install which ever they claim will make you able to program the Picaxe chips!

Then you want to find the part that says

AXE027 PICAXE USB Download Cable

Step 45: Hook up your computer, start programming

Picture of Hook up your computer, start programming

Install the driver and cable as described, and plug the jack into the board.

nsert all batteries in your robot.. wait.. wait.. sniff.. anything smells funny? No sparks, no smoke? No? OK, go on then.

Most versions of the Picaxe programming software have some form of menu item called "Options". Enter that, and look for a page or tab that says "Mode". Some editors even open this very page for you when you first start up the program.

Here you should find a buttom that says "Firmware" or "Check firmware version". Click that.

Now what should happen is that the editor talks to the cable, that talks to the Microcontroller, and asks it what kind of a Picaxe chip it is. It should return something like "28X1/40X1", and this should be displayed on the screen for you.

If yes, then good; You have contact. Now somewhere in the same screens, you should be able to set the mode of the editor, set it to 28X1/40X1.

(It is a big mystery to me why this has to happen, by the way; Apparently the editor can see what kind of chip is there, so why on earth can it just not set it by itself?. hmm.. let me know if you find this reasone one day ;)

Ok, if you get any errors, cannot find the Microcontroller or something is reported wrong with the cable, I will have to ask you to lean on Picaxe's help and manuals. It's usually very simple, so try again if something is wrong. Or try from another computer, just to see how it should work, and then try the first one again, and bug track that way.

Now, enter the main programming editor; It is like a big text editor. If no project is open, go to "File"; and open "New Basic" / "New".


In here write this:

 

servo 0, 150

wait 2

 

This is your first program, and it is very simple. The first line tells the Microcontroller that there is a servo on pin 0, and that it should be put in the center position, which is 150.

The next line tells it to think about life in 2 seconds (which gives the servo time to turn).

And after this, the Microcontroller will stop doing anything at all, it will go zombie!

Write it in, and transfer the code to the microcontroller. That is done on some systems by pressing F5. No, wait, I think it is so on all systems. On all that I can test from here anyway :) You could also click "Program".

You should be told that the program is transferring, and then magic should happen; The servo should turn to the center position.

Perhaps it did not do much, but that may be because it was already in center.

Try to hold down the "Reset" switch that is placed on the board, while turning the servo to one side. Then let go of the reset, and it should turn back in place.

Perhaps you do not think it is center, but it is. But maybe your servo "horn" is just mounted awkward. In the middle of it, there is a screw. Unscrew and take of the horn, make sure the microcontroller have put the servo in center, and then screw on the "horn"(disc, or what ever) again, so it is the way you think it should look like when centered.

Now, let's try to move it to another side, lets extend the program:

 

servo 0, 75

wait 2

servo 0, 225

wait 2

servo 0, 150

wait 2

 

the servo command should only be using values from 75 to 225, which is the most a standard servo can go to either side. Values out of this range is not recommended, may produce funny results.

Every time you run this program (you can unplug the cable, take out the batteries, and turn it on again without the cable), it will start from the top. And every time you press reset, it will.

If you'd like it to go in a loop, you can add a label in the top, and in the bottom make it go back to that label. We make up any name for a label, just a single word, followed by a ":", watch:

 

servofun:

servo 0, 75

wait 2

servo 0, 225

wait 2

servo 0, 150

wait 2

goto servofun

 

Now it just goes on and on.. Try to play around some with it, change values etc, if you'd like :)

...

OK, back to building the robot ;)

Step 46: Hooking up the Sharp

Picture of Hooking up the Sharp

Plug in the wire to the Sharp, if it was not in from the shop. in other words; Make sure there are 3 wires coming from the Sharp. Your colors may be different, but I have red, black and white, which is pretty meaningful for V, G and Signal.

You may need to add female headers to the wires, like I did below. These can also be in any color, of course. However, I have soldered 3 of same colors on, so you can trust the colors in my picture, to be leading you to which cable goes to where.

Be careful to check that you are plugging this right in, because the Sharp can fry pretty easily.

In the picture below, you can see what goes to where. The stick and strange setup is just to make sure you can see the wires and their colors :)

Step 47:

Picture of
ou should have 3 little black things called Shortening Blocks. What they do is simply conect 2 pins next to each other.

If you don't have any, you can always just use a female-to-female instead, like I did on the last one, with a litle white cable. The blogs are smart because they dont take up any space, a wire is smart, because it can reach from one end to the other of a board.

As you can see I did on the picture, connect analogue input 1, 2 and 3 to V, using shrtening blocks or female-to-female.
 

Why this? A short, and not very scientific explanation is; these 4 inputs (0, 1, 2 and 3) are analogue. Which means they mesure "how much preasure is on the line". However, they are connected, if they like it or not. And so, a little preasure on one of them actually does something to the next. They are "left floating". By tying the 3 that we do not use to V, they are just returning "full value", and they are not left floating. So the last one, number 0, that we use, is way more accurate.

I have not read documentation that tells you to do this, however, I have at several ocations experienced strange readings, till I tied all unused analogue pins to either ground or V. oh.. and in fact I am writing documentation here (sort of :) So now it is written in the documentation to do this! :)

Step 48: Face on!

Picture of Face on!

Make sure the servo faces middle, 150!

With a new piece of tape, mount the Sharp IR on the servo horn, facing forward.

 

Tadaa! :)


You're done building the basics!
The design may wary, you may have used other parts etc.. But if you have connected as described, here are some tips to get started programming your robot:

Step 49:

Picture of

Programming



Enter this code into your editor, and press F5 while the robot is connected:


main:

readadc 0, b0

debug

goto main


Now take your hand in front of the robot´s head and notice how the variable b0 changes value. You can use the knowledge gained to decide what should happen when (how close things should get before..)

You may notice how things start to go "wrong" if stuff is too close to the "eyes"; The Sharp is made to work with stuff that is from 10-80 CM away. Things that are closer appears to be further way, which can be quite a challenge to program.

You can get many other distance sensors that do not have this problem. However the Sharp is the cheapest, and easiset to program, so that's why I made such a "bad" choise for you, sorry ;) Look around and see what everyone are using, before you decide for an upgrade.

Now I advise you to put your robot up on a matchbox or similar, as the wheels will start turning.

Enter this code into your editor, and press F5 while the robot is connected:


high 4

low 5


One of the wheels should turn in one direction. Does your wheels turn forward? If so, this is the instruction for that wheel to turn forward.

If the wheel is turning backwards, you can try this:


low 4

high 5


To turn the other wheel, you need to enter


high 6

low 7


(or the other way around for opposite direction.)

What happens here is that by using only the options available to the microcontroller; power on or off (High / Low) on it's pins, it is commanding the motor controller to set motor A or B in forward or reverse mode.

 

low 4

low 5

low 6

low 7

 

stops all motors



The servo you have already tried.

All the way to one side is:

 

servo 0, 75 wait 2

 

the other side is: 

 

servo 0, 225 wait 2



- and center:

 

servo 0, 150 wait 2

Here is a small program that will (should, if all is well, and you insert the right parameters for high/low to suit your wiring to the motors) make the robot drive around, stop in front of things, look to each side to decide which is the best, turn that way, and drive towards new adventures. In the code I have made socalled remarks: Stuff written to explain you what is going on.

You can write such comments or remarks yourself in the code, it is a good idea to keep track.

They are writen with a ' sign. However, copying this text from here might alter that to something else, and you will have to fix that manually, sorry. Your programming editor has color codes, that will help showing you what it recognizes as comments and what as code.

 

Symbol dangerlevel = 70 ' how far away should thing be, before we react?
symbol turn = 300 ' this sets how much should be turned
symbol servo_turn = 700 ' This sets for how long time we should wait for the servo to turn (depending on it´s speed) before we measure distance

main: ' the main loop
readadc 1, b1 ' read how much distance ahead
if b1 < dangerlevel then
gosub nodanger ' if nothing ahead, drive forward
else
gosub whichway ' if obstacle ahead then decide which way is better
end if
goto main ' this ends the loop, the rest are only sub-routines


nodanger:' this should be your combination to make the robot drive forward, these you most likely need to adjust to fit the way you have wired your robots motors
high 5 : high 6 : low 4 : low 7
return


whichway:
gosub totalhalt ' first stop!

'Look one way:
gosub lturn ' look to one side
pause servo_turn ' wait for the servo to be finished turning
readadc 1, b1
gosub totalhalt


'Look the other way:
gosub rturn ' look to another side
pause servo_turn ' wait for the servo to be finished turning
readadc 1, b2
gosub totalhalt

' Decide which is the better way:
if b1
gosub body_lturn
else
gosub body_rturn
end if
return

body_lturn:
high 6 : low 5 : low 7 : high 4 ' this should be your combination that turns the robot one way
pause turn : gosub totalhalt
return

body_rturn:
high 5 : low 6 : low 4 : high 7 ' this should be your combination that turns the robot the other way
pause turn : gosub totalhalt
return

rturn:
servo 0, 100 ' look to one side
return

lturn:
servo 0, 200 ' look to the other side
return

totalhalt:
low 4 : low 5 : low 6 : low 7 ' low on all 4 halts the robot!
Servo 0,150 ' face forward
wait 1 ' freeze all for one second
return

 

 

With some clever programming and tweaking, you can make the robot drive, turn it´s head, make decisions, make small adjustments, turn towards “interesting holes” such as doorways, all working at the same time, while driving. It looks pretty cool if you make the robot spin while the head is turning ;)


 

 

Fun time

You could also attach a lamp or LED to pin 2 & ground, and write (remember LED´s need to turn the right way around)


High 2

 

to turn on the lamp, and 

 

Low 2


to turn it off ;)


- How about a Laser-pen, mounted on an extra servo? Then you could make the robot turn the laser around, and turn it on and off, pointing out places.. you can do anything now :)

Pressing "Help" in the programming editors brings out all sorts of interesting tutorials and info!


 

Perhaps try this:

Pull out the servo, and take up the yellow chip. Insert the Darlington that you took out earlier. Hook up the speaker to the 2 pins above where the servo was, tat is output 1. And throw in the LED, or whatever it was that you found on output 2. Then program it something like this:

 

sound 1, (100, 30)

high 2

wait 1

low 2

sound 1, (105, 60)

 

That should make a sound and turn something on, make a new sound and turn it off again.

 

Or the more interesting, make sure the Sharp is still in, hook a speaker up to pin 1, and then program this:

 

noise:

readadc 0, b0

sound 1, (b0, 2)

goto noise

 

Here is the program I used to make the video in the intro :)

Ce ya!
(I hang out on letsmakerobots.com most of the time)

1-40 of 71Next »
yhdesai2 years ago
HOW MUCH WILL BE COST TO MAKE THIS ROBOT.

if you do not live in usa it is about 300 euros

Diparna3 months ago
I love ur project and o want to make it,please please tell me the price of this project

its about 300 euros if you do not live in USA

where could i buy the shorting blocks to ship to finland, there is a website called pololu which is the only one i could find which ships internationally but i dont trust it so please help me!

makershaker052 months ago

Niiiiicccccceeee! You're great! Thanks for this ible:)!

GwimolasG2 months ago

how

TanM8 months ago

Cool dude!

AnthonyM310 months ago

Hello fritsl what kind of solder do you need does it matter because ive never really heard of a solder and imgonna buy one and I wondered if there is a certain type of solder or solder iron

scottbaker828 made it!1 year ago

Thank you so much for the instructable, I just finished it!

The only issue I had was in the programming, where in the sample program you used "readadc1", unlike the "readadc0" used when introducing the range of values from Sharp. So "readadc1, b1" caused b1 to always be 255, b/c the analog pin 1 was connected to V by the shorting block. Seems simple now, but took me ages to pinpoint this as the problem! I hope this can help someone else! :)

DSC03249.JPG
pdiasanta2 years ago
hi! where can i buy the materials?? does it have online selling?
and how much will it cost?
This is really cool. Thank you for adding this. Will the store(solarbotics) be getting your kit in stock any time soon? I was also wondering if this kit is RoHS compliant? Thanks.
null3 years ago
where do i find these?
null3 years ago
where do i find these?
pbebergal5 years ago
I have wanted to build a robot like this for a long time, but I have been putting it off because of all the support behind Arduino. Would it be possible to get advice on how to build this same robot, but with an Arduino. It seems like I am going to invest in a microcontroller, I should do so with something that I am more likey going to do more with besides the bot... any suggestions? I am not dissing Pic, just so much maker momentum seems to be with Arduino...
Check out Scratch for Arduino!
fritsl (author)  pbebergal5 years ago
I always wanted to do this walkthrough with an Arduino based setup, as a parallel, so people could chose.

However, things are just that more "complex" with Arduino. One line of code makes a servo go to a direction with Picaxe. And that is even one simple and logic line of code, that your dog can understand:

servo 1, 150

With Arduino, you'd have to upload a library first, and then deal with many lines of hard-to explain-for-the-novice-code and syntax.

- For doing the excact same thing. And that's just the servo, things just get so much hairier. I want people to get a good start, not to meet a wall.

But I like Arduino, and every now and then I think about how to present it as "your first project", in the spirit of the walkthrough above. I Just have not found a way yet :)

There are, however, tons of walkthroughs on how to get started with Arduino. I am just focusing on how to get started building robots here. And for that purpose, I have chosen the components listed, because I believe they are the best mix for a starter who wants to dive in to fun-zone right away :)
RoboZek fritsl4 years ago
I have had experience with Parallax's Basic Stamp board. As you said with Pic, it takes only a line of code for a servo to go in a direction. Same with Basic Stamp, it doesn't require much more then pic, PULSIN 1, 150. I believe that is the right way to write it. I haven't used it in awhile. But Basic Stamp can be very easy.

http://www.parallax.com/

You can go here to find more about it.

I never have used Picaxe or Arduino before. I hope to use both.

This is still very good.
Thanks, that makes a lot of sense. Do you think Picaxe is the way to get started with Microcontrollers in general?
You could also put a 5v voltage regulator on it and use 6 rechargeable batteries, you would get 5v and for a longer time because you could use more batteries.
you are a genius. you make robotics easy to understand. thank you
sci4me4 years ago
Not that your robots not good (i actually luv it) but i think i can make an easier and cooler one. 1 rc car and 1 picaxe 08 motor controller board. Thats Practicelly all it takes. And sensors for a good and cool robot. Nice job though.
Raziel74 years ago
could you give me the artist's name who sings the song in part 1 of your instructional video?

I tried looking it up on Google and there are people in forums wondering the same thing (they heard it on a you tube video) but no answers so far.

Great song and great video
macman8084 years ago
can i use an ultrasonic range finder instead of the sharp, without having to change the program?
punit1134 years ago
wow,its ousom,great
how to do that?????
account3r25 years ago
Yeah! Mario Bros!

Johnny Rex5 years ago
fritsl, i need help, im 12 years old and very smart, i bought the robot and put it together but im having trouble programming it, sometimes when i type in engine codes like: high 4 low 5 high 6 low 7 i hear the engines moving but the wheels arent, the wheels arent touching anything either. ill try recharging the batteries but dont think thats it. Plz respond, i need help and this was a pretty decent investment for me. all i have left to do is figure out the right engine codes and ill be done completely, unless the wheels wont turn like now. THANKS!! and to all who are wondering if they should uy this I RECCOMEND IT!!! =]
Pkranger885 years ago
Great job, with one caviat though.  If you use a lighter to activate heat shrink tubing, you need to keep the flame from having too much direct contact with the tubing.  A heat gun, or a hair dryer, works better and is more appropriate anyway.  I've caught heat shrink on fire before by using a lighter. 
fritsl (author)  Pkranger885 years ago
I do not agree with you, but thanks for the points, now people can try both ways :)
I'm sorry you don't agree, but you admitted yourself, that you burnt the wires.  You can deny reality all you want but eventually it bites you in the butt.   Good luck.
Pkranger88, Your opinion may be based on the type of heat shrink tubing you are using.  There are several types of heat shrink tubing available, and they are not all created equally.  One of my favorites is polyolefin.  I personally use heat shrink tubing almost every day of my life, and have done so since the early 80's.  I carry a Bic lighter for that explicit purpose.  While in some cases a heat gun is more appropriate, in many cases it is not.  Your version of "reality" does not necessarily coincide with someone else's.  In my experience and my "reality" you'd have to be a real dunce to catch good quality shrink tubing on fire!  The fact that the author disagrees with you doesn't indicate a denial of reality.  It may simply indicate a difference in experience and or skill level.  Good luck to you as well.
Most heat shrink tubes are flame retardant anyway, I usually use my soldering iron to shrink them.
Once you get the hang of it it's not too hard, as you probably know.
tanmanknex5 years ago
Did you think about putting the "head" on the back of the robot facing forward? That should give you enough space so that it won't freak out when something's close, shouldn't it?
fritsl (author)  tanmanknex5 years ago
If you are thinking about the "dead zone" within 10 CM's in front of the Sharp, you are absolutely right!
Cool, it's not very often that that happens. ;)
Amuraxis5 years ago
Very well presented and detailed instructable, can't wait for payday to make this badboy

5*'s
Kryptonite5 years ago
Yay! The kit's on sale!

...damn.... bit expensive. Looks like I'll have to save up!
alex_shoal5 years ago
 good job.
1-40 of 71Next »