Arduino Controlled Toy Car
This is the second part in my Arduino controlled toy cars.Once again it is an obstacle avoidance one.
In this car I'm using an Arduino Nano instead of an Uno.The motor driver is a L298N module.
Supplies
What you need also :
-two dc motors,the best ones are gear motors for reasons that become clear later on
-a HC-SR04 sensor
-Dupont cables female-female
-battery holders and clip leads,in this case a 2 x 18650 battery holder and 9V clip leads
Tools
-soldering iron
-rotary tool like a Dremel
-hot glue gun
-screw driver
Prepare Your Car and Install the Motors
First take off the top part to see what space you have to work with.In this case the two rear wheels are mounted separately which is a big plus.I wanted to put the motors there but couldn't take the wheels off easily.So in the front they had to go .My two DC motors just fitted in there ,I had to enlarge the wheel base a little bit to accommodate the wheels.
That went well,however when I tested the car later I found out those motors didn't had enough torque to move the car.This is why it is better to use gear motors here.So instead of these motors,I choose the well known yellow ones from China.Due to lack of space these were hot glued standing up with a wooden support between them.
Adding Power
The motors are powered with 2 lithium-ion batteries,and no you don't get 9900 mAh from these ones(I think they showed about 500 mAh in a test).The Arduino is powered with a 9V battery.This car has plenty of space to place the batteries.
The End Product,a Video........and the Code
In the video you can see the car wiggles a little bit,this is because I had to modify the shafts of the motors a little bit to fit the wheels.I think having the sensor close to the ground is a good thing to have .The car seems to spot the obstacles in time without getting stuck in corners.
The code is the same as I used in my other toy car project ...a simple copy and paste job for you.