Recently, I had the rewarding experience of assembling and driving my first Arduino-powered Bluetooth-controlled car. This project was part of my larger Arduino RoboMaster series, but building my own RC car has been a long-standing dream. Now that I’ve successfully made the car run wirelessly, I feel a deep sense of achievement.
Over time, I’ve written several guides to help others understand key components and concepts, including using DC motors with the L293D motor driver module, HC-05 Bluetooth module programming, DC motor control using Arduino, understanding the H-bridge principle, and DC motor speed control using MOSFETs. I’ve also demonstrated simulations and practical tutorials for these components.
Below are pictures of my first RC Bluetooth car in action.
Controlling the Car with a Mobile App
The car is controlled via a mobile app called RC Bluetooth Car, which sends commands through Bluetooth to the car's module. I’ve detailed how this system works in previous articles, including testing the Arduino program and troubleshooting motor issues. Here's the Arduino Bluetooth code I used for the car:
#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
}
Challenges and Observations
Initially, I encountered issues with one wheel not spinning properly, especially when driving forward or turning left. My initial suspicion was either insufficient power from the batteries or an imbalance in the motor outputs, possibly due to the L293D motor shield.
After upgrading to a new Lithium-Ion battery charger, which charged the batteries to 3.8V, the Bluetooth module and motors performed better. Surprisingly, the issue of the stalled wheel resolved itself after a few test runs.
Below is a video demonstration of the arduino bluetooth car:
Planned Improvements
From this experience, I’ve identified a few enhancements to make:
- Dedicated Power Supply for the Bluetooth Module: When the batteries are low, the HC-05 module fails to power on. A separate power source will ensure consistent performance.
- Incorporating Battery Management: I plan to include an automatic or manual battery charging system in the RoboMaster project. I’ve already acquired a 3S 10A 18650 BMS lithium battery protection board for this purpose.
Future Battery Charger Projects
Given my limited charging capacity, I plan to build additional Lithium-Ion chargers using LM317 voltage regulators and DIY battery holders. My earlier attempt at using the TP4056 module failed due to potential soldering errors or loose connections. However, I’m determined to create reliable chargers for my 18650 batteries.
This journey has been both challenging and rewarding. If you’re interested in similar projects, check out my related posts:
- Building RoboMaster with Arduino - Part 2
- Quick HC-05 AT Startup Guide - Part 3
- Testing RC Bluetooth Car App and Motor Code - Part 4
- Lithium Ion Battery and Charger - Part 5
Stay tuned for updates as I continue to refine my Arduino Bluetooth car and related projects!