Here we are going to implement a bot which is going to detect obstacle and according to that, it going to change its direction.
Step 1: Objective of This Project
In this project we are going to make Avoid obstacle Robot. Here we are going to interface three ultrasonic sensors with arduino uno. We are also using two Dc motors so for that we need one motor driver module because Arduino itself is not capable to give that much amount of current which is able to run dc motors. So for that we are using Motor Driver Module (L298D).
Step 2: Software Used
As we are using Arduino Uno Module so for that you have to use Arduino IDE
Here is the link to download Arduino IDE
Step 3: Hardware Used
These are the Components you required for this project
1. Arduino UNO:
2. Motor Driver Module (L298D)
3. Ultrasonic Sensor(HcSR04)
4. Dc gear Motor
5. Jumper Wires
And one Robot Car Battery Box Chassis Kit you will need for this project so you can get that one as well.
Here I'm going to explain you briefly about these components
1. Arduino Uno:
Arduino/Genuino Uno is a microcontroller board based on the ATmega328P (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header and a reset button.
2. Ultrasonic Sensor(HC-SR04 ):
Ultrasonic range sensor( HC - SR04) provides 2cm - 400cm distance measurement function, the ranging accuracy can reach to 3mm. The modules includes ultrasonic transmitters, receiver and control circuit.
3. Motor Driver(L298N):
The L298N H-bridge module can be used with motors that have a voltage of between 5 and 35V DC. With the module used in this tutorial, there is also an onboard 5V regulator, so if your supply voltage is up to 12V you can also source 5V from the board.
4. Dc gear Motor: In this project we are using two Dc gear motor
Step 4: Controlling DC Motors
To control one or two DC motors is quite easy with the L298N H-bridge module. First connect each motor to the A and B connections on the L298N module. If you’re using two motors for a robot (etc) ensure that the polarity of the motors is the same on both inputs. Otherwise you may need to swap them over when you set both motors to forward and one goes backwards!
Next, connect your power supply – the positive to pin 4 on the module and negative/GND to pin 5. If you supply is up to 12V you can leave in the 12V jumper (point 3 in the image above) and 5V will be available from pin 6 on the module. This can be fed to your Arduino’s 5V pin to power it from the motors’ power supply. Don’t forget to connect Arduino GND to pin 5 on the module as well to complete the circuit.
Now you will need six digital output pins on your Arduino, two of which need to be PWM (pulse-width modulation) pins. PWM pins are denoted by the tilde (“~”) next to the pin number, for example:
Finally, connect the Arduino digital output pins to the driver module. In our example we have two DC motors, so digital pins D9, D8, D7 and D6 will be connected to pins IN1, IN2, IN3 and IN4 respectively. Then connect D10 to module pin 7 (remove the jumper first) and D5 to module pin 12 (again, remove the jumper).
The motor direction is controlled by sending a HIGH or LOW signal to the drive for each motor (or channel). For example for motor one, a HIGH to IN1 and a LOW to IN2 will cause it to turn in one direction, and a LOW and HIGH will cause it to turn in the other direction.
However the motors will not turn until a HIGH is set to the enable pin (7 for motor one, 12 for motor two). And they can be turned off with a LOW to the same pin(s). However if you need to control the speed of the motors, the PWM signal from the digital pin connected to the enable pin can take care of it.
Step 5: Project Description:
First we are going to connect three ultrasonic sensor with our Arduino board. Then according to program our three ultrasonic sensor going to generate a trigger signal which is going to receive by our echo pin of Ultrasonic Sensor. Then we are going to run an algorithm according to which we are going to manipulate our desire distance for obstacle detection then we are going to control our motor rotation direction for movement of our bot. 50CM(Front),15CM (Each Side).
Here above you can see the circuit diagram of this circuit
Step 6: Project Code and Video
You can download source code of this project from the link below
Or else you can also go to our github page : here
And here you can watch it out in action in our video
If you will finish all the steps correctly then you will have one robotic bot with three ultrasonic sensor. So Enjoy your Avoid Obstacle Robot
If you have any question regarding this project feel free to comment us below
For more project you can visit our youtube channel here
And in case you need any help - you can contact us at firstname.lastname@example.org. In case you need any embedded systems development or IoT work - you can send an email to us at email@example.com