Today lets build a robot car
First we will decide what functions we want in our car. I want following functions;
1. Manual Control
2. Line following
3. Obstacle avoidance
4. Colorful LEDs animation
6. Mobile control using Bluetooth Communication
7. Rechargeable battery
Lets start with simple design of car and controlling it. For the movement of car I will be using two dc
gear motor. I will use a H Bridge to control the speed and direction of motor.
Truth table for this H-Bridge(L2983D) is as follow;
We will give this signal to H-Bridge using arduino pro mini. We will connect H-bridge to arduino pins
3,5,6 and 11 as they have pwm which we need for speed control.
In arduino IDE we will first define the pins and create a function to convert joystick values to H-bridge
value according to its truth table.
For buzzer we will simply connect a mini buzzer to pin 7 of arduino.
It will look something like this.
Colorful RGB animation.
For RGB lights i will be using neopixel Ws281b rgb led strips. It only uses one data pin to control the
entire strip. I am using pin 10 to control RGB strip. I am using adafruit neopixel library to control ths
For line following i will be using two IR proximity sensor. I have a tutorial on how these sensor works,
You can buy them commercially but i made
my own. I will hookup them to pin 4 and 8.
when one sensor is on black line it will turn
in one way and when the other sensor is on
black it will turn in the other way, otherwise
it will go straight.
For powering the car i will be using Li-ion battery of 2000mAH and 3.7v which will be boosted to 5v
using MT3608 boost converter. This battery can last for quite a long time .
For charging I will use TP4056 charging module. This module charges the
battery and as well as protects the battery from over-charging, overdischarging,
over-current and short circuit protection. You can use any 5v
mobile charger to charge battery.
I am also adding 10k resistor between battery + terminal and analog 0 pin
of arduino to later get remaining battery.
There is a small problem, when you start the car from rest position and accelerate it quickly. A huge
surge current passes through this module which consider it as over-current and cut of the power, to
address this problem we have to see how this module is detecting over-current.
The charging module have following functional circuit;
By looking at these pictures we came to
know that charging module have
Dw01A protection chip, which senses
voltage drop across power mosfets at
CS pin. So we will add a 1k resistor at
CS pin GND. This will make a voltage
divider and will lower the sensing
voltage at higher currents.
You can also check this forum.
To detect obstacle we will need a ultrasonic sensor which uses sonar to detect objects. We will mount
it on servo motor so that we get 180° of view. In this mode normally
car will move straight until it detects some object. when it detects
some object, it will stop look left and right and will turn to the
position it see no object.
Another problem occurs when we use servo. The problem is servo
does not work with neopixel. Why that’s is happening? for that we have to see how these libraries
work. Both libraries uses 16 bit timer of the arduino to make time interrupts which are required for
normal operation of servo and neo pixel and unfortunately arduino pro mini which uses Atmega328p
only have one 16 bit timer i.e timer 1 that means both libraries conflict with each other. To solve this
problem we have to use TicoServo library for servo which uses pwm mode of timer 1 to generate
signal required for servo.
If you want details on this topic you can check this link.
For mobile control we want an app to communicate to arduino using bluetooth. I will be using
RemoteXY for that. You can find it on Play Store.
GUI of app will be made on RemoteXY website. We will add joystick to control car, bar to show
remaining battery, slide switch to select current driving mode, a button for buzzer and finally a color
wheel for RGB lights. Of course you can add according to your taste
and our beautiful car is ready.
Complete code is here;