Hey!
It's good to meet you again. In this post, we are posting Arduino Codes, Electronic and Mechanical Simulations, and a full guide for how to make an "Obstacle Avoiding Robot".
Obstacle Avoiding Robot | HC SR-04 | Arduino
The motive of making Obstacle Avoiding Robot
This Robot will be very useful for
The motive of making Obstacle Avoiding Robot
This Robot will be very useful for
- Making an Automatic Vacuum Cleaner.
- Many competitions in different Institutes.
- Making Projects in different Institutes.
- Many other miscellaneous activities.
This post is divided into two parts :
Part 2- Basic Mechanical structure for "Obstacle Avoiding Robot"
The following points are discussed in this part-
Part 1 : Electronic Simulations and Arduino Coding
- Ultrasonic Sensor
- Distance Calculation
- Coding for Ultrasonic Sensor with and without using NewPing library.
- Electronic Simulation for obstacle detection.
Here we are starting with
Ultrasonic Sensor :Distance Calculation :
Coding for Ultrasonic Sensor without using NewPing Library
Electronic Simulation in Proteus
Coding for Ultrasonic Sensor using NewPing Library
It detects the distance of closest object in front of it typically from 3 cm to 400 cm. It works by sending out a burst of ultrasound and listening for the echo when it bounces off an object. It pings the obstacles with ultrasound. The Arduino or Genuino board sends a short pulse to trigger the detection, then listen for a reflected pulse using pulseIn( ) function. pulseIn( ) function returns the total time ( in microseconds) taken by pulse to Go - Reflect - Return back.
Distance calculated by distance = speed * time will be twice of the actual distance between sensor and obstacle (by the principle of sound reflection. You can contact me for understanding this principle). Half of the calculated distance gives the actual distance between obstacle and detector.
It is the best way to understand the basic principle and working of HC SR-04 Ultrasonic sensor without using NewPing library because here we are going to deal with it manually.
I am sure that you will get a deeper understanding and good learning.
Here I have prepared a custom code to calculate distance
#define Pin_Trig 5
#define Pin_Echo 4
void setup()
{
Serial.begin(9600);
}
void loop()
{
long duration,cm,inches;
pinMode(Pin_Trig,OUTPUT);
pinMode(Pin_Echo,INPUT);
digitalWrite(Pin_Trig,LOW);
delayMicroseconds(2);
digitalWrite(Pin_Trig,HIGH);
delayMicroseconds(5);
digitalWrite(Pin_Trig,LOW);
duration = pulseIn(Pin_Echo, HIGH);
inches = microsecondsTOInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
}
long microsecondsTOInches(long microseconds)
{
return microseconds / 74 / 2 ;
}
long microsecondsToCentimeters(long microseconds)
{
return microseconds / 29 / 2;
}
You can download the code from link given below
In order start designing this simulation in proteus, first download the library of ultrasonic sensor for proteus from here. Get Library
Now upload the respective code in the arduino and finally get ready to run the simulation.
on running the simulation here on the Serial port the detected distance is displayed in inches as well as in centimeters.
Hoping you have got basic idea of its working.
Now let's do the same job using NewPing library
Here I prepared a simple code for distance calculation using NewPing library
#include <NewPing.h>
#define Pin_Echo 4
#define Pin_Trig 5
#define Max_Distance 500
NewPing sensor(Pin_Trig, Pin_Echo, Max_Distance);
void setup()
{
Serial.begin(9600);
}
void loop()
{
delay(50);
int time_taken = sensor.ping();
int obstacle_distance=time_taken/US_ROUNDTRIP_CM;
Serial.print("Obstacle detected at");
Serial.print( obstacle_distance);
Serial.print(" Centimeter Ahead");
Serial.println();
}
You can download the code from the link given below
Now Design the simulation upload code and run it.
Animation & Designing-
Well there is no need to of Mechanics, for an obstacle avoiding robot, it will be good if it will be simple, for the body we can use the plastic box for obstacle avoiding robot, and if we want to increase the strength of our bot then we can use aluminum 3mm sheet to make the body, and L-clamp for attaching the motor.
Note- In aluminum make sure that there should not be any type of conductivity, it may cause a short circuit.
I used plywood of 3mm thickness to make obstacle avoiding robot, its strength is good and there is no electric conductivity.
Motors used-
We can use Gear motors & BO motors and I will prefer BO Motors, They are light in weight and reliable.
Wheels used-
Because of its lighter weight, wheels we don't have to use wider wheels i.e, the width of 4cm, it will be best if we use 1cm width, and 7cm Dia Wheels, our bot will be lighter and effective.
Screw & Bolts used-
Screw Bolts used in making bot should not be longer in length they must be of 5mm- 7mm in length, if we are going to build this bot then we have to plan everything.
There is also a simpler method for making a robot without using screw & clamp, it will be lighter but it's not reliable, if we have glue gun we can paste motors on plywood or metal sheet, it will make our work easy, but it can break any time, we cannot trust on a structure like that.
Requirements-
BO Motors-4, Screw Bolts- 12 (5-7mm), Plywood/PlasticBox/Metal Sheet (20cm*20cm).
Tools required-
Plier, Screwdriver, Saw. (These tools are always helpful)
Animation & Designing of Robot-
Video Explanation-
In this video you can see that a bot is moving towards a wall when it gets close to a wall, it moves back, and take right and left turn, obstacle detected is seen on LCD, the ultrasonic sensor detects any obstacle comes in its way and avoids it.
This animation video is made in Autodesk Fusion 360.
For more applications on robotics, Subscribe to our Blog.
Motors used-
We can use Gear motors & BO motors and I will prefer BO Motors, They are light in weight and reliable.
Wheels used-
Because of its lighter weight, wheels we don't have to use wider wheels i.e, the width of 4cm, it will be best if we use 1cm width, and 7cm Dia Wheels, our bot will be lighter and effective.
Screw & Bolts used-
Screw Bolts used in making bot should not be longer in length they must be of 5mm- 7mm in length, if we are going to build this bot then we have to plan everything.
There is also a simpler method for making a robot without using screw & clamp, it will be lighter but it's not reliable, if we have glue gun we can paste motors on plywood or metal sheet, it will make our work easy, but it can break any time, we cannot trust on a structure like that.
Requirements-
BO Motors-4, Screw Bolts- 12 (5-7mm), Plywood/PlasticBox/Metal Sheet (20cm*20cm).
Tools required-
Plier, Screwdriver, Saw. (These tools are always helpful)
Animation & Designing of Robot-
Video Explanation-
In this video you can see that a bot is moving towards a wall when it gets close to a wall, it moves back, and take right and left turn, obstacle detected is seen on LCD, the ultrasonic sensor detects any obstacle comes in its way and avoids it.
This animation video is made in Autodesk Fusion 360.
For more applications on robotics, Subscribe to our Blog.
The mechanical structure is as important as Electronic if the mechanical structure fails, there are pretty many chances that electronic structure will no longer live, To build the perfect mechanical structure you should have a basic knowledge about mechanics Which I discussed in my previous blogs please follow the archives.
#PictureThe robot is designed and animated in Fusion 360
Here is a design basic design video of Obstacle avoiding ROBOT, it's a basic part of a video in this blog we are just trying to teach about the calculation of distance with ultrasonic sensors, in next video we will discuss the working model and animation of a robot, working.
#Video
Comments