In this project, an Arduino based obstacle avoiding robot is designed that will use an ultrasonic sensor to detect all the obstacles in its path.

How to Avoid Obstacles using Ultrasonic Sensor?

As we know the abstract of our project, let us move a step ahead and gather some for information to start the project.

Step 1: Collecting the Components

The best approach to start any project is to make a list of complete components at the start and going through a brief study of each component. This helps us in avoiding the inconveniences in the middle of the project. A complete list of all the components used in this project is given below.

Step 2: Studying the Components

Now, as we have a complete list of all the components, let us move one step forward and go through a brief study of the working of every component. Arduino nano is a breadboard-friendly microcontroller board that is used to control or carry out different tasks in a circuit. We burn a  C Code on Arduino Nano to tell the microcontroller board how and what operations to perform. Arduino Nano has exactly the same functionality as Arduino Uno but in quite a small size. The microcontroller on the Arduino Nano board is ATmega328p. The L298N is a high current and high voltage integrated circuit. It is a dual full-bridge designed to accept standard TTL logic. It has two enable inputs that allow the device to operate independently. Two motors can be connected and operated at the same time. The speed of the motors is varied through the PWM pins. Pulse Width Modulation (PWM) is a technique in which the flow of voltage in any electronic component can be controlled. This module has an H-Bridge which is responsible for the control of rotation direction in the motors by inverting the direction of the current. The Enable pin A and Enable Pin B are used to change the speed of both of the motors. This module can operate between 5 and 35V and peak current up to 2A. The Input Pin1 and Input Pin2 and for First motor and the Input Pin3 and Input Pin4 are for the second Motor. HC-SR04 board is an ultrasonic sensor which is used to determine the distance between two objects. It consists of a transmitter and a receiver. The transmitter converts the electrical signal into an ultrasonic signal and the receiver converts the ultrasonic signal back to the electrical signal. When the transmitter sends an ultrasonic wave, it reflects after colliding with a certain object. The distance is calculated by using the time, that ultrasonic signal takes to go from the transmitter and come back to the receiver.

Step 3: Assembling the Components

Now as we now know the working of most of the components used, let us start assembling all the components and produce an obstacle avoiding robot.

Step 4: Getting Started with Arduino

If you are not already familiar with the Arduino IDE, don’t worry because a step by step procedure to set-up and use Arduino IDE with a microcontroller board is explained below. To download the code, click here.

Step 5: Understanding the Code

The code is well commented and self-explanatory. But still, it is explained below

  1. At the start of the code, all the pins of the Arduino Nano board that are connected to the ultrasonic sensor and motor driver module, are initialized. Pin6 and Pin9 are PWM pins that can vary the flow of voltage to vary the speed of the Robot. Two variables, duration, and distance are initialized to store data that will later be used to calculate the distance of the ultrasonic sensor and the obstacle.
  2. void setup() is a function that is used to set al the pins used, as INPUT and OUTPUT. Baud Rate is defined in this function. Baud Rate is the speed of communication by which the microcontroller board communicates with the sensors integrated with it.
  3. void loop() is a function that runs repeatedly in a cycle. In this function, we tell the microcontroller board how and what operations to carry out. Here, first, the trigger pin is set to send a signal which will be detected by the echo pin. Then the time that is taken by the ultrasonic signal to travel from and back to the sensor is calculated and saved in the variable duration. Then this time is used in a formula to calculate the distance of the obstacle and the ultrasonic sensor. Then a condition is applied that if the distance is more than 5ocm, the robot will move forward in a straight line and if the distance is less than 50cm, the robot will take a sharp right turn.

Applications

So here was the procedure to make an obstacle avoiding robot This obstacle avoiding technology can be sued in other applications too. Some of these applications are as follows.

How To Make A Floor Cleaning Robot Using Ultrasonic Sensor?How To Make A Smoke Alarm For Your Kitchen Using Arduino?How To Make A Digital Thermometer Using Arduino?How To Make A Smart Stick For Blind People Using Arduino? How To Make Obstacle Avoiding Robot Using Arduino  - 85How To Make Obstacle Avoiding Robot Using Arduino  - 84How To Make Obstacle Avoiding Robot Using Arduino  - 37How To Make Obstacle Avoiding Robot Using Arduino  - 61How To Make Obstacle Avoiding Robot Using Arduino  - 44How To Make Obstacle Avoiding Robot Using Arduino  - 36How To Make Obstacle Avoiding Robot Using Arduino  - 7How To Make Obstacle Avoiding Robot Using Arduino  - 23How To Make Obstacle Avoiding Robot Using Arduino  - 69How To Make Obstacle Avoiding Robot Using Arduino  - 78