Today, I successfully assembled and drove my first Arduino based Bluetooth car. Though, I build this car as part of my Arduino Robomaster project, my wish to make RC car on my own was a long time plan. Finally having run the car wirelessly I feel a sense of accomplishment. I wrote a lot of articles and tutorials on how to use DC motor with L293D motor driver module, how to use HC-05 Bluetooth module, how to write program to control a DC motor, how DC motor H-bridge works, have shown lots of L293D DC motor simulation with Proteus, explain the L293D motor module, DC motor Speed Control with MOSFET etc.
Below are pictures of my first self build remote controlled car.
As already said, the car is controlled using mobile phone app, RC Bluetooth Car, which sends command using Bluetooth radio to the Bluetooth RC car module. In my previous blog posts, I have explained the basic of how this system works, showed you the testing of the Arduino program, testing the motors etc. Below is the Arduino Bluetooth program code that I used.
#include <AFMotor.h>
//initial motors pin
AF_DCMotor motor1(1, MOTOR12_1KHZ);
AF_DCMotor motor2(2, MOTOR12_1KHZ);
AF_DCMotor motor3(3, MOTOR34_1KHZ);
AF_DCMotor motor4(4, MOTOR34_1KHZ);
char command;
void setup()
{
Serial.begin(9600); //Set the baud rate to your Bluetooth module.
}
void loop() {
if (Serial.available() > 0) {
command = Serial.read();
stop(); //initialize with motors stopped
switch (command) {
case 'F':
forward();
break;
case 'B':
back();
break;
case 'L':
left();
break;
case 'R':
right();
break;
case 'S':
stop();
break;
}
}
}
void forward()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(FORWARD); //rotate the motor clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(FORWARD); //rotate the motor clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(FORWARD); //rotate the motor clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(FORWARD); //rotate the motor clockwise
}
void back()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(BACKWARD); //rotate the motor anti-clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(BACKWARD); //rotate the motor anti-clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(BACKWARD); //rotate the motor anti-clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(BACKWARD); //rotate the motor anti-clockwise
}
void left()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(BACKWARD); //rotate the motor anti-clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(BACKWARD); //rotate the motor anti-clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(FORWARD); //rotate the motor clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(FORWARD); //rotate the motor clockwise
}
void right()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(FORWARD); //rotate the motor clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(FORWARD); //rotate the motor clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(BACKWARD); //rotate the motor anti-clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(BACKWARD); //rotate the motor anti-clockwise
}
void stop()
{
motor1.setSpeed(0); //Define minimum velocity
motor1.run(RELEASE); //stop the motor when release the button
motor2.setSpeed(0); //Define minimum velocity
motor2.run(RELEASE); //rotate the motor clockwise
motor3.setSpeed(0); //Define minimum velocity
motor3.run(RELEASE); //stop the motor when release the button
motor4.setSpeed(0); //Define minimum velocity
motor4.run(RELEASE); //stop the motor when release the button
}
The following video demonstrates the Arduino Bluetooth Car.
During the testing of this RC Bluetooth Car, I used both Lithium Ion battery and the wall socket power supply and I noted that in the forward direction, only three wheels would spin and the fourth would be stalled. Similarly when left was clicked, one of the four wheels would not spin. I could not understand why this happened. My guesses were- like the battery not producing voltage current or there is not balanced output to the motor and so the problem is the L293D Motor Shield.
But after I bought new Lithium Ion charger shown below, the Lithium Ion batteries charged to upto 3.8V(as shown in my digital meter). I thought I would see below 3.7V. Using then these fully charged batteries the car and the bluetooth module operated as expected.
When driving for the first time I still got the one wheel not spinning problem. But then after driving the RC car, all the wheels started to work. The problem was simply gone.
I have noted several things during this first drive which has led me to think several modification to the car power supply. First, I want to provide a separate power supply for the HC-05 Bluetooth module. This is because, when the power is not enough from the the three lithium ion batteries, the Bluetooth module won't turn on. Second thing I liked to do is to incorporate automatic or manual battery charging system on the Arduino RoboMaster that I wanted to actually build. For this I have already bought the 3s 10A 11.1V 12.6V 18650 PCM BMS lithium li-ion battery charger protection board circuit.
Not directly related to the work on the car but I have also plan to build more Lithium Ion chargers using single and double battery holder case for 18650 Lithium Ion Batteries and using LM317 voltage regulator IC. I want to make more battery chargers because I have only one battery charger which can charge only two out of my four lithium ion batteries. I have tried to build a Lithium Ion Battery and Charger using TP4056 - TC4056A Lithium Battery Charger and Protection Module but it is not working. Both the blue and red leds are turned on. I build it with a DIY battery holder. The charger is not working because either I accidentally solder joined and shorted the battery and the load pins. Or there is no connection between the battery holder that i build with the battery terminals.
Since my immediate is how to get the all the batteries charged quickly I have plan to make some lithium ion chargers for 18650 sized batteries.
References
# Building RoboMaster with Arduino - Part 2
# Quick HC-05 AT startup guide - Arduino RoboMaster Part 3
# Testing RC Bluetooth Car App and Motor Code -Arduino RoboMaster Part 4
# Lithium Ion Battery and Charger - Arduino RoboMaster Part 5