Simple Ultrasonic Arduino Robot That Avoids Walls

by 43Foldz in Circuits > Arduino

792 Views, 12 Favorites, 0 Comments

Simple Ultrasonic Arduino Robot That Avoids Walls

IMG_7112.jpg
IMG_7113.jpg

The robot uses an ultrasonic distance sensor to detect walls and turn before hitting them.

Supplies

REQUIRED

1) Arduino board ideally a NANO : amazon

2) 4 pin ultrasonic distance sensor : amazon

3) l293D motor controller : amazon

4) Power switch

5) 9v power supply : I used a rechargeable 9v battery

6) 2x motor of your choice I use these : amazon

OPTIONAL

Depending on how you are planning on building it you may want some basic solder materials including jumper wires, breadboard, etc.

Wire the Components Together

Screenshot 2025-10-11 110704.png

Follow the diagram above to wire the components together. Pay close attention to the motors because these wires are referenced in the code later.

Upload the Provided Code

Screenshot 2025-10-11 111327.png
Screenshot 2025-10-11 111539.png

The code has comments describing what the different functions do. It is broken down into four functions forward, backward, left, and right. You can write your own program using these if you find the original code to be too basic, or if you wish for the code to function differently.

Finish the Final Assembly

IMG_7114.jpg
IMG_7115.jpg
IMG_7116.jpg

Arrange the parts on whatever board you are using so that the motors can be connected to the wheels and touching the floor, and they can push the chassis forward. Additionally make room for the power switch and power pack. ATTENTION : Make sure that the sensor is parallel the FLOOR and NOT the chassis. otherwise the signal might get messed up.

Note : If the motors are not fully aligned the robot will not go perfectly straight, this is what happened to mine. Keep this in mind when mounting the motors.

Also linked are the files I used for the wheels that attach to the yellow motors. The caster in the front I found here. The wheels fit on the shafts well but I fused them together using a soldering iron as seen in the photo. And to add more grip to the wheels I used rubber bands around them as demonstrated in the first photos.

Downloads

Video

Here is a link to a video of the finished product.