Let's Make Robots!

How to build your first robot - Part II - navigation


Your browser is not able to display this multimedia content.

Your browser is not able to display this multimedia content.

clean_navigation.BAS6.17 KB

This is Part II of How to build your first robot - tutorial.

you can just take the cool navigation-code in here and have fun with it, or you can follow the whole instruction, or the parts that you like. I try to make it as general and open as possible.

Here is part III of this tutorial - I recomend that you browse this as well!


You have made a robot, something like this: How to build your first robot

You have read my deep thoughts on how to move on with the programming "Don't program your robot.. Teach it!", and you have made tricks with your robot, messed around with it, had some fun and is ready to move on.

Perhaps you have tried out this little trick of seeing what your robot sees.

You have seen on the video of "Making Skiwalker", and seen on the pictures of "Yellow Drum Machine" (the pics in the bottom) - that you do not need much for materials to make a robot; Melt-glue, double sided tape, sticks, and you are go!

If so, this part II should be a breeze! You can make this robot in 45 minutes, no sweat.


First, let's make the robot on the picture above. Try to duplicate the main parts, that is the main task here.

It shuld not need much explantion, it is excaxtly like the one from How to build your first robot - only differences:

  • Instead of Sharp sensor, I use SRF05
  • The servo is a smaller one, and a fast one - you can get these in any size and speed
  • The gearing on the motors is lower, so I have a faster robot (though it is not a speed-king, lol)
  • instead of just taping it all together, I have used 3 sticks to form some sort of a "chassis"

The closer you get to this, the easier it will be to follow the rest, but of course you can just do it your way, with whatever parts you have etc.

In the first tutorial I wrote that you could make some fancy code for the robot.

I now present you for some code that I have made, it is what is used on the video. It is an example, there are thousands and millions of ways to evolve, you should do it your way. This is just to try to open your eyes, and share what I have learned after countless hours of trial and error.

Try to alter some of the numbers to tune in to your setup, and read the guidelines in the code. That way you can get a robot like the one on the video, and we are going to use that as a base for Part III in this tutorial...

Find the attached code in the top of the post.

.. And the screwdriver-trick on the video?

Well.. Look for places where the code says

servo Servopin,head

and add, just after it

servo 1,head

If you are adding another servo on pin 1.

Think about what to attach instead of the screwdriver?

Something with an LED on? And insert some on/off in the code for the LED? Or a fan? or.. :D


Stay tuned. This bot is getting more enhancements now..

And if some of the comments below does not make sense, please understand that I am changing this over time, so the comments may have been for an earlier text here :)

Thanks, and do post what robots you make, to inspire back. Thank you.

/ Fritsl

Comment viewing options

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

The answer:

Hey Chris, I have looked at the code and your question.

Yes, aparently it is strange. Yes, perhaps it is a leftover from some debugging. And yes, sometimes I make strange code, because I think it is fun to make something that is not really logic at first sight, but when diving into it, it is pure logic. Sort of like easter eggs.

Weather this one is a bug, a debuging option, or an easter egg, I really cannot tell, as my brain only allows me to look at old stuff in a very limited time - it simply halts and start inventing new, so I cannot go deeper into it, sorry.

Have you seen the new omni-code? It is cool!

I added some sharp sensors (in the "add extra stuff here" section and quickly found why you are looping back to the driveahead code... It seems that once the sharps were triggered (I was using them for side sensors) the robot would be stuck in a loop and just keep sliding the direction it was triggered!! The "goto driveahead" loopie-loop is to stop any turns from locking on. I added a gosub afterturn to my sharp sensor code and they worked great! So there you go. To be honest, yes I am working on some new autodrive code for walter but I am not cutting a pasting your stuff. I was just sorta "reverse engineering" it to see if what you did is any better than what I got. What I found is that we pretty much wrote the same code with just a few tiny differences. I'll check out the other code you suggest -- I am trying to write not only some very smooth code, but also trying to be a gentle as I can on my motor driver so I am going through as much drive code as I can to find all the good parts! --Thanks dude.

Forget about Walter swinging his head... I played with the "top of the head" mounted sonar and quickly found it was WAY to high off the ground to be any good. I have pulled the SRF005 and relocated it to the underside of the chassis on a servo in the standard way. I added 2 sharps in the corners to catch walls parallel to travel and so far this seems to be a solid set-up.


Word, I wonder what is going to pop up from W's head then?

I'll donate you a laser pointer as replacement :)?

Hi fritsl,

I've just download the 'clean_navigation.bas' file on this page. When i use 'simulate' on the editor programme it comes up with the error =


gosub puls

Error: Only 16 gosub commands allowed!


Is this something I've done or is it something that doesn't affect the running of the program?


Also when I downloaded the program it came down as a .BAS.txt file so had to copy/paste into a new basic file.


You should set up your Picaxe to 256 gosubs or something. It is done in the Options or something :)

(I am not on a PC with the editor installed here)


In Fact, This Is My First Time Here..

I Gonna Build My First Robot.

But How Can I Control The Robot By Voice..ex( Go And Turn Right..)ty all

Good luck. That would require you to either spend a ton of cash on something that can do voice recognition or be very smart to make it yourself.
Here is someone with experience in voice recognition. Haven't seen him around lately. But all of his projects are worthy of your attention.

ty guys, great effort..

i hope we can do it by the voice..it will be more easy to use it by webcam too. then we can contact our robots with our eyes....like (eyetwig)software..