Saturday, June 15, 2024

Obstacle-Avoiding Autonomous Car Robot Using Arduino

efy testedThe use of autonomous systems to perform relevant and delicate tasks is fast growing and their application in various fields cannot be over emphasized. But obstacle avoidance is an important task in robotics, as the autonomous robot’s aim is to reach the destination without collisions. One type of autonomous robot that can detect obstacles and edges, and takes alternative paths free of obstacles and edges, is a real-time obstacle avoiding edge detection robot.

Fig. 1: Authors’ prototype
Fig. 1: Authors’ prototype 

This project proposes a robot with intelligence built into it, which guides it whenever an obstacle comes its way using an algorithm. The design allows the robot to navigate in an unknown environment by avoiding collisions. Obstacle avoidance in robots can bring more flexibility in varying environments and make them much more efficient, so that their continuous human monitoring is not required. The authors’ prototype is show in Fig. 1.

Bill of Material
1. Arduino Uno R3 -1
2. Motor driver shield -1
3. Wheels -4
4. DC gear motors -4
5. Servo motor -1
6. Ultrasonic sensor -1
7. Sensor stand -1
8. Lipo battery -1
9. Acrylic sheet -1
10. Male and female jumper wires

Block diagram of the obstacle avoiding robot is shown in Fig. 2 while its circuit diagram is shown in Fig. 3. This robot is constructed using ATmega 8 family’s microcontroller Arduino Uno R3. When its ultrasonic sensor detects an obstacle or an edge, it sends a command to the microcontroller. The microcontroller, based on the received input signal, directs the robot to push in an alternative direction by actuating the motors that are interfaced with it via a motor driver. Depending on the situation, the robot is able to choose a clear path and the decision-making process of obstacle avoidance and edge detection occurs spontaneously.

Fig. 2: Block diagram of the obstacle-avoiding robot
Fig. 2: Block diagram of the obstacle-avoiding robot
Fig. 3: Circuit diagram of the obstacle-avoiding robot
Fig. 3: Circuit diagram of the obstacle-avoiding robot

The sensor plays an important role in this project. First, the transmitter sends ultrasonic signal bursts at 40kHz. This signal gets reflected back when an object comes in front of the sensor and it is received by the receiver. The ultrasonic sensor generates high-frequency sound waves and evaluates the echo that reaches back to the receiver. So, by using this technique, the ultrasonic waves calculate the distance between the car and the reflected objects continuously.

- Advertisement -
Fig. 4: Soldering wire to a gear motor
Fig. 4: Soldering wire to a gear motor

After an obstacle detection, the car changes its direction by making an autonomous decision. It can measure the distance between itself and surrounding objects in real time.

Fig. 5: Attaching gear motor to chassis
Fig. 5: Attaching gear motor to chassis


The program is written in Arduino programming language Sketch. Arduino IDE 1.8.11 has been used to compile and upload the program in the prototype. The project needs various libraries, which have to be included in the external header file for programming.

Fig. 6: Attaching wheel to gear motor
Fig. 6: Attaching wheel to gear motor

For uploading the source code ARDUINO_OBSTACLE_AVOIDING_CAR.ino into Arduino Uno board, connect the Arduino board to desktop/laptop using a USB cable. Next, select the board and port and upload the source code.

- Advertisement -
Figs 7, 8, and 9: Chassis assembly as per Step 2
Figs 7, 8, and 9: Chassis assembly as per Step 2

Construction and testing

First of all, upload the source code into the Arduino Uno and follow the steps mentioned below to assemble the robot.

Step 1. Assembling the chassis (see Fig. 4, Fig. 5, and Fig. 6):

  • Solder the wire to positive and GND of the DC gear motors
  • Attach the DC gear motors to the bottom of the chassis
  • Attach the wheels to the DC motors

Step 2. Mounting the components:

  • Screw the Arduino onto top chassis
  • Then plug the motor driver shield into Arduino
  • Connect the motors to correct pair of terminals—the front motors to front terminals of motor shield and the rear motors to rear terminals of motor shield

    Fig. 10: Servo setup
    Fig. 10: Servo setup

Step 3. Setting up the servo:
• Attach the servo on top of the chassis
• Plug the servo into Servo 1 (SER1) header pins on the shield

Step 4. Preparing the ultrasonic sensor: (Fig. 11: Sensor connections)
Place the ultrasonic sensor on the servo using the sensor stand. Then plug four wires into the sensor using female jumpers. Next, connect sensor to Arduino Uno as described below:
TRIGpin 2 (AO)
ECHO→pin 13 (A1)

Fig. 11: Sensor connections
Fig. 11: Sensor connections

Step 5. Powering the robot:
Connect the Lipo battery to the L293D motor driver as follows:
Lipo battery (+)→+12V
Lipo battery (-)→GND

Fig. 12: Power supply connections
Fig. 12: Power supply connections

The obstacle-avoiding robot is now ready! It can be used for such applications as:

  • Mobile navigation systems, military and law enforcement, search and rescue, and forest conservation.
  • For household work like automatic vacuum cleaning.
  • With proper programming, for weightlifting and auto parking assistance.

Download source code

Dr S. Rajan is Professor, while Mythili M. is final year student at Department of ECE, Velalar College of Engineering and Technology, Thindal, Erode, Tamil Nadu


Unique DIY Projects

Electronics News

Truly Innovative Tech

MOst Popular Videos

Electronics Components