Obstacle Avoiding Robot





Introduction: Obstacle Avoiding Robot

About: I am 27 years old engineering student from Oulu in Finland. I make these projects as a hobby, and it would be fun to also make these as a full-time job. I have a 6 year old son. My goal is to make these inst...

What could be more awesome than building your own robot.

This is how to do it your self.

Banana for scale in the last picture.

For mobile users. Watch the video from here!

Find the building kit from here!

Step 1: Components.

I used my previous project's shield and ultrasound sensor in this project.

Learn how to make the Radar from HERE! The build is explained there.

The base for the whole build is an old HDD lid. It is light weight and it hold's its shape well.

The wheels are just from an old toy car.

Two servos for the wheels is needed and one servo for the radar.

And of course some kind of Arduino based board is needed. I used Intel Edison+ Arduino breakout board.

Step 2: Making a Forever Rotating Servo.

Forever rotating servo means that it will turn more than the basic 0-180 degrees.

The forever rotating servo is great for this type usage. You can change the speed by entering differed value to the servo and also you can change the direction of rotation.

First find a simple test code from the internet to set up your servo.

I used a basic potentiometer on a shield and set the servo to 90 degrees. This way it is in the middle of its original rotation and it is easiest to program. Also the rotation speed of the servo is the same in both 0 and 180 degree.

Then remove the cap from the servo and pull out the gears.

In one gear there should be a small pin that stops the servo if it is turning too much. Cut that off.

Then make absolutely sure that the potentiometer is at 90 degree position and drop a small drop of superglue on the potentiometer to jam it on its place.

Then just put all the gears back and test the workings of the servo.

Step 3:

Attach your servos to the wheels and attach the servos to the base of your robot.

I used hot glue for basically connecting everything since it is very durable and hold's tightly on its place.

Don't worry about the front wheels at this point. I will get to them later.

Step 4: Add Connectors to the Radar Shield.

If you have not checked out my RADAR project yet, i suggest to look at it now since mostly of this pit of the project is done in my previously project.

Add two simple connectors for the two servos.

A slight modification to the radar shield had to be done however. This is just for convenience of the build.

The trigger and echo pins were moved to 7 and 8 pin.

And the two servos are connected to pin 3 and 5.

The radar servo is in pin 9.

Step 5: Coding and Testing

Lift the project on to something so the wheels will be up, this just eases the coding process.

If you have any questions about the code, just ask and i will try to answer them.

Start the code by making all the needed definitions and global variables.

To change the distance when the robot stops, change the dangerThresh to something else. like 10.

The threshold is in centimeters.

#define ECHOPIN 8 #define TRIGPIN 7

const int RForward = 0; const int RBackward = 180; const int LForward = RBackward; const int LBackward = RForward; const int RNeutral = 90; const int LNeutral = 90;

const int dangerThresh = 20; int leftDistance, rightDistance; Servo panMotor; Servo leftMotor; Servo rightMotor; long duration;

Then it's time for setup.

void setup()
{ Serial.begin(115200); rightMotor.attach(5); leftMotor.attach(3); panMotor.attach(9); panMotor.write(75); pinMode(ECHOPIN, INPUT); pinMode(TRIGPIN, OUTPUT); }

And then for the main program, loop.

void loop()
{ int distanceFwd = Distance(); if (distanceFwd>dangerThresh) { leftMotor.write(LForward); rightMotor.write(RForward); } else { leftMotor.write(LNeutral); rightMotor.write(RNeutral); panMotor.write(0); delay(500); rightDistance = Distance(); delay(500); panMotor.write(150); delay(700); leftDistance = Distance(); delay(500); panMotor.write(75); delay(100); compareDistance(); } }

Then there is two subroutines.

One to compare the measured distances. This one tells the robot to go left or right, witch has more space to move.

void compareDistance()
{ if (leftDistance>rightDistance) { leftMotor.write(LBackward); rightMotor.write(RForward); delay(700); } else if (rightDistance>leftDistance) { leftMotor.write(LForward); rightMotor.write(RBackward); delay(700); } else { leftMotor.write(LForward); rightMotor.write(RBackward); delay(1000); } }

And subroutine for the distance calculation.

long Distance()
{ digitalWrite(TRIGPIN, LOW); delayMicroseconds(2); digitalWrite(TRIGPIN, HIGH); delayMicroseconds(10); digitalWrite(TRIGPIN, LOW);

float distance = pulseIn(ECHOPIN, HIGH); distance= distance/58.2; return(distance); }

Step 6: Adding Battery Pack.

The robots usage is pretty limited if it need's a cord to run, so at this point is good to make a battery pack for it.

The pack hold's six AA (LR6) battery's witch is plenty for the project. I haven't tried how long it can run.

Once again i used hot glue to hold the pack in its place.

The Edison is not hold with anything on the board. It just fits snugly on the base board so it wont need any. This means that changing the battery's is easy.

Step 7: Time for the Front Wheels.

These wheels are the same kind of wheels that are on the servos.

I used a BBQ stick to make the axle and a two pits of plastic to hold it in it's place.

Once again, Hot glue everything like there is no tomorrow.

Step 8: Done.

Now it is finally done.

I could say this is pretty easy project to do. It just takes some time to collect all the needed pits and parts.

Anyway, I hope you liked the build!

If you did, Make sure to follow me to get more projects!

Thank you for reading.

PS. Remember to watch the video ;)



    • Oil Contest

      Oil Contest
    • Water Contest

      Water Contest
    • Clocks Contest

      Clocks Contest

    40 Discussions

    Hey ! This is a very nice job ! I want make the same one but your building kit link is dead. Can you fix it please ? Thank you very much :)

    Thanks for giving the idea I was able to complete the robot and once again thanks for the idea of making this awesome robot.

    Hello, seeing this tutorial, I wonder if it would be possible, do the ultrasound rotate rotate and detect all around you? a radius of a circle, for example of a meter, he would turn and detect all approach this circle.

    Great work. For the video, I'd prefer to hear commentary instead of shredding guitar. Why do people feel embarrassed about technical prowess, and have to make a statement "See, I'm not a nerd -- this cool music proves it"? But excellent project.

    2 replies

    Hi. Thanks for commenting. The reason i don't like to talk on my videos is that i'm not comfortable with it since i'm not a native speaker. Text is much more convenient way to "communicate" in videos. And also the music is free to use. :)

    FYI. I have a degree in music (bass, drums and guitar) and also i'm Electronics technician, soon to be Engineer in the same field.

    We Finns just like to listen metal, bang our heads to the wall and communicate as less as possible.

    I get it -- thanks for setting me straight. I apologize for sounding critical. I guess I was cranky. :) Thanks for your project! -Cheers

    How do you power the board, do the Intel Edison use 5V power supply? Btw, that batteries seem to be from Finland :)

    5 replies

    Intel Edison has a build in regulator of 5 volts. So if you use like in this project 6*1.5 Volt battery's you will get 9 Volts that is regulated to 5 Volts for the board. It can handle Volts from 0 to about 15 Volts.

    Jep Jep. Patterit on halvinta lähikaupan Smarket laatua ;D

    I cant find any information about that.

    This is what the datasheet says:

    Galileo is powered via an AC-to-DC adapter, connected by plugging a 2.1mm center-positive plug into the
    board's power jack. The recommended output rating of the power adapter is 5V at up to 3A.

    So i think that means there is no regulator on that?

    http://www.intel.com/newsroom/kits/quark/galileo/p... Here is a link to the datasheet

    Great! The mute button is made just for you. Rest of that don't mind the music can keep audio on.

    Everybody wins!

    Have a nice day.

    How do you connect your sensor? Do you connect it directly to your analog pin?