Arduino Obstacle Avoiding Robot





Introduction: Arduino Obstacle Avoiding Robot

In this instructable I will show you how to make your own obstacle avoiding robot!

We will use the Arduino uno board and an ultrasonic sensor. If the robot detects an object in front of it, with the help of a small servo motor, it scans the area left and right in order to find the best way to turn.

It has also a notification LED, an buzzer to play a tone when an object is detected and an button for changing the function of the robot (stopped / moving forward).

Official page:

It's very easy to make it!

So, let's get started!

Step 1: What You Will Need

For this project you will need:

You will also need one big (metal) paperclip and an bead to make the back supporting wheel.

For the robot base I used a piece of plexiglass (12 x 9.5 cm). You can also use a piece of wood or metal (or two cd/dvd disks ).

The cost of the entire project is about 20$ :)


  • Drill machine
  • Super glue
  • Screw driver
  • Hot gun glue (optional)


We will use an 9V battery to power on our robot because it's small and cheap, but it's not very powerful and will be empty after about one hour. Consider if you want to use a rechargeable battery pack (min 6V, max 7V) that will be more powerful but it will be also more expensive and bigger than the 9V battery.

Step 2: Prepare the Robot Base

Place all the hardware parts on plexiglass piece and mark it with a pen in order to open the holes with a drill. (1st image).

Begin with the bottom side, use a super glue to mount motors in the plexiglass piece. Make sure that they are perfectly aligned - use a triangle ruler (2nd image). Now attach the 9V battery holder.

Tip: You can also open holes for the motors and battery cables .

Step 3: Put the Hardware Parts on It

Use the spacers, screws and nuts to attach the Arduino uno board and the L298 module on plexiglass piece. The mini breadboard can be easily attached on it with the adhesive tape that already have at the bottom of it (1st image).

Now it's time to make the rear supporting wheel, use the paper clip and bead (2nd image). Finally, use a super glue (or hot gun glue) to attach it on the bottom side of the plexiglass.

Step 4: The "eyes" of Our Robot

Use a super glue to attach the tiny servo motor in the front side of our robot. Watch the first image above to understand how to put the ultrasonic sensor in the servo motor by using a small gear piece.

The second above image shows the completed part that will be the "eyes" of our robot.

Step 5: The Circuit

Now it's the time to make our circuit! The connections are pretty easy, watch the above image with the breadboard circuit schematic.

Tip: Use the breadboard only for the LED, button and buzzer, this will keep it simple and you can use the remain area to add more stuff on the future.

Step 6: The Code

Here is the code, embedded using Codebender!

Codebender is an online Arduino IDE - It's the easiest way to program your Arduino board directly from your browser! Just click on the "Run on Arduino" button and that's it! Try it! It's really amazing!

Plug an battery on it and press the function button once, your robot will start moving forward. To stop it, just press the button for one more time.

You can also press the 'Edit' button and start making your modification in the sketch.

For example, try to change the '10' cm value that is the distance that will make the robot to stop and 'look' for a clear path.

Note: if your robot doesn't move forward, try to change the pins of the motors (motorA1 and motorA2 or motorB1 and motorB2).

Step 7: Well Done!

Now you have your own Arduino Obstacle Avoiding Robot!!!

Check my page for more cool Arduino projects:

I hope you liked this, let me know in the comments below, I would like to see photos of your cool robots!

2 People Made This Project!


  • Science of Cooking

    Science of Cooking
  • Trash to Treasure

    Trash to Treasure
  • Pocket-Sized Contest

    Pocket-Sized Contest

We have a be nice policy.
Please be positive and constructive.




How can we control the car ? Suppose if we want to move the left or somewhere else, how this could have been done since there is no remote or any other blue-tooth, wi-fi or antenna connected to the circuit ....


By any chance, does this robot detect holes? For example, if it is driven on a table, will it identify the edge and stop?

Hey can I use only one motor?

Yes, but you will only have forward and backward movement, no steering.

this was really helpful
thanks a lot

Hey there, where did you get that L298n into fritzing ? how did you add it ? thank you

Can anybody please tell me what coding language is being used here?

its embedded c(im a beginner)

i want to add this robot to my smart walking stick cane. How do I do that as far as putting both arduino codes together?

what is the code to do it with only the L298N and the distance sensor?

wow its super..i made this robot only single is successful completed