Arduino Car Projects: Build an Obstacle Avoiding Robot With Less Than $30

A lot of people want to start building robots but they don’t know where to start. It may seem too sophisticated for beginners when in reality it is not. Hopefully, there is an endless source of knowledge called the internet, where you can find literally every information you want.

This is a good project that can help you build and program an obstacle avoiding car using the Arduino board.

Arduino car project

Here is what we want the car to do: navigate and avoid obstacles.

We could decide to add an option to control this car remotely using Bluetooth, but we will stick with the autonomous behavior for the sake of letting you grasp how simple working with Arduino is.

Our robot will sense obstacles with an ultrasonic sensor mounted on its front, the brain of it will be an Arduino UNO clone, we will use a cheap chassis that you can easily buy online with very popular cheap motors. To control the motors we will need 2 channel motor controllers also called H bridge (it is made out of transistors whose connections look like the letter H and that’s why it is named H bridge, this way of connection between transistors allows you to change the direction of rotation of a motor).

We will also need some cables to connect everything together. And just to let you know, soldering is not needed in this tutorial.

Here is a list of parts needed for this project:

That’s all you need and it shouldn’t cost more than $30. You can also find a lot of kits having all these components.

Let’s start by fixing all the components to the chassis. You can use M3 screws.

While assembling, make sure that you will be able to connect the cables to those components. Sometimes it is impossible to fix for example an Arduino with 4 screws so you can use 3 or at least 2 to make it rigidly tied to the chassis.

To fix the ultrasonic sensor, I used a 3D printed part that I designed in AutoDesk Fusion 360, you can download it here. If you do not have a 3D printer, don’t worry, you can find a cheap sensor holder on Amazon or simply mount it on the chassis the best way you can.

On the image above, you can see how I placed the mounting screw to receive the Arduino board. On the next image, the Arduino board is fixed to the chassis.

There were only 2 holes to mount the motor driver so I used them.

Here are all the connections we have to make. Different colors represent different signals and voltages. Before plugging in the battery, make sure that everything is connected correctly, otherwise, you can burn something.

If a motor is rotating in the opposite direction than it should, you have to change its polarity (just swap the black cable with the red one).

The code

And now it’s time to upload the code into the Arduino board. Copy the code above, Open you Arduino IDE, paste the code and upload it to the board.

The code is a very simple one. It just lets the robot go forward as long as there is no obstacles in front of it when it senses an obstacle, it randomly rotates left or right and goes forward again until the next obstacle has been found.

You don’t need to add any extra library to get this working, the code is all you need. It is so simple I think you will have no problem understanding it. It is kind of perfect for beginners. As an exercise, you can try writing your own program similar to this one, this way you will better understand how things work and hopefully be able to create a more advanced program based on this project. You can also play with variables at the beginning of the programs. They determine the rotation time, frequency of sensor reads and so on.

Now we can test our robot. Put it on the floor and plug it to power. Your robot should start moving 3 seconds after connecting the battery.

You might also like:

2 thoughts on “Arduino Car Projects: Build an Obstacle Avoiding Robot With Less Than $30”

  1. Project completed. Now I am trying to add a servo to the sensor, to have it turn its head left and right, find the next direction to go to before turning its body.
    Thanks for this!

Leave a Comment

X