How to Make Obstacle Avoiding Car Using Arduino
by ROBO HUB in Circuits > Arduino
8755 Views, 115 Favorites, 0 Comments
How to Make Obstacle Avoiding Car Using Arduino
Hey guys in this project I have made an Obstacle avoidance car that uses arduino, This robotic car will automatically avoid going in the path of any obstacles! How cool is that?
This robot car serves as an ultimate source of learning if you are willing to learn about robotics and arduino along with circuits and programming.
This Instructables provides you a step by step-by-step instructions on how you can make this cool educational gadget in your house in a very easy way.
Note that it can be programmed in many ways as you like depending on the type of application which you will be putting this car in the future, To make it easier for everyone i will be explaining the most required information so that you are not wasting any time.
I have given a working video of this car in the end of this Instructables make sure you are not missing that out, now let us head over to building this project.
Supplies
Bo motors x 4 with wheels from here
Ultrasonic sensor
Micro servo with flat horn attachment
Wheels for motor x 4
Arduino Uno servo shield
Jumper wires
18650 battery and holder
Switch
Soldering iron
Extra pieces of wire
3d printer (inexpensive) and filament(optional)
Hot glue and superglue
Design and 3d Printing
This is an optional step if you don't have a 3d printer you can directly skip this part and carry on with the next step, But those creative people who are still reading this let me explain what I did here.
For the motor holder or in other words for the body of the car I used a 3d printed rectangular frame, This does nothing but hold all the electronic components and serve as a base body, I will be using the PLA filament to print this part on my 3d printer.
There are various other alternatives for this, You can use a piece of cardboard or a piece of MDF wood for this purpose the main thing here is the cleanliness of the project that we get by using these materials.
I suggest going either with 3d printing or using some kit that holds the BO motor and wheels.
If you are 3d printing make sure you are using the settings on the slicer like i did(refer last image of this step for the settings)
Downloads
Wheels
As I mentioned earlier you can use MDF or strong cardboard as a replacement to 3d 3D-printed body.
This makes the project look a lot cleaner, start by pasting the BO motor to the base part, I will use good quality hot glue for this purpose, so make sure you are not overheating the glue.
As an alternative, you can also use superglue, But I won't recommend using that because once you glue that it is nearly not possible to take it off and reuse the bo motor in future projects.
Repeat the same steps for the other 3 motors as well, after this is complete you can connect the wheels to the shafts of the BO motor.
I chose to use the standard type of wheels if you have more budget you can upgrade to a more fancy version of the wheels but I recommend using these standard wheels since they serve the purpose best here.
If your BO motor does not have the wires soldered solder it before we are proceeding with the next step.
Circuit and Program
Before assembling all the components to the body of the car upload the code to the arduino uno board, This step is very easy all you have to do is connect the programming cable to the computer and connect the uno board to the other end of the cable.
Open arduino IDE and paste the below code to the IDE, Check for the proper board type and port number and click on upload there is no need to make any changes to the code.
After you upload the code disconnect the cable and now we can build the connections between different electronics here.
There are 4 motors in total the front and rear are paired to work together, Connect the motors as given in the circuit, To make it easier i have color coded the wires that are connect to the motor
Connect the servo 1 slot on the shield, ultrasonic sensors Trig and Echo are connected to A0 and A1 pins while the power pins are to 5v and Gnd respectively.
Ext power pins to the power supply + of the battery and other ends will be connected via the switch.
Power on the project and check if the movement of the wheels are fine, if the rotation is different just change the terminals and it should work fine now.
You also can simplify this circuit with a Simple small PCB, Complete your electronic projects in the best way from PCBWay
Why them? They have provided me with the best PCB and The quality is just amazing compared to other providers in the market
Have some Stl files to 3d print? You should check their 3d printing services too
Check Here for Rigid-flex Pcbs with this your circuit becomes flexible! I have added the images to this step kindly check.
A revolutionary solution that combines the best of both rigid and flexible circuitry to elevate your electronic projects to new heights.
With their expertise in advanced manufacturing techniques, they offer a seamless integration of rigid and flexible components, ensuring enhanced reliability, durability, and space-saving benefits
Downloads
Wiring the Components
Place the motor shield on the body and secure it with hot glue, before connecting the wires to the shield make sure to check the motor shaft direction of rotation, To do this you can simply connect the terminals of the lithium-ion battery.
The rear and back wheels should follow the same direction of rotation, if you have a different direction of rotation change the terminals of the motor and now you should be good to go.
After you connect the BO motor to the servo shield connect the micro servo to the shield, this should be easy since we have terminals on the board that enable easy connection.
Finally, connect the ultrasonic sensor to the servo shield, I have used a 3d printed frame to hold the sensor, if you don't have any type of holder you can use a piece of wood or strong plastic.
To the base of this wood or plastic attach the servo horn, i choose the flat ones, just glue them to the base and allow them to dry in the end just connect the servo shaft to this horn.
Do not screw these horns before testing this car this is because sometimes the servo shaft will be moved manually for checking and this may cause a change in direction of servo movement that impacts the overall working of the car
Final Assembly
After you test the movement of wheels and the working of other hardware components we can start to assemble them on the body of the robot car, Since we have made a mission to make this as small as possible using the area effectively is the key to achieve this.
I will start placing the servo and marking that area followed by applying a few drops of hot glue, Now gently place the servo and press for a few seconds to make it stick firmly to the body.
Now attach the ultrasonic sensor to the base of which we have already glued the horns, if you don't have a frame for the ultrasonic sensor you can glue the sensor to a flat cardboard or wooden piece and perform the same action like i did.
After you place the sensor attach the battery to the board and add a switch to control the power, Note that i have give this battery connection part on the circuit diagram in the above steps.
How to Use
Using this homemade gadget is fun! Yeah seeing your creation doing some crazy stuff is another level of joy.
To use this robotic car all you have to do is turn on the power switch and leave it on its own, this will start to move and when an obstacle is detected it will stop and take another direction and even if it detects any sort of obstacle then it changes the path.
The other sides will be continuously scanned by the sensor and servo helps to achieve this and direct the car towards free space.
For the demonstration of how this works, I have added a gif in the front of which a wall is present and our obstacle avoidance car is managing to come back and move in another way.
This was all about building this project, If you have any doubts feel free to watch the video, This video has all the instructions to build this project and also the working video that shows the car's abilities.
Thanks and let me know how did your build come out.