Arduino Bluetooth 4WD Car With Steering

by vitorccsiqueira in Circuits > Arduino

8 Views, 0 Favorites, 0 Comments

Arduino Bluetooth 4WD Car With Steering

car_front_view.jpg
car_front_view.jpg
car_rear_view.jpg
car_pcb_detail.jpg
IMG_20231008_230035420.jpg
IMG_20231008_230122580.jpg
Bluetooth Arduino Car - Driving Test
Bluetooth Arduino Car - Using Mobile App

Bluetooth remote-controlled 4WD car using an Arduino Nano v3 board with steering performed by a servo motor

Supplies

  1. 01 - 4WD Car Chassis with steering (see section below)
  2. 04 - DC Motors (3v - 6v)
  3. 04 - Wheels
  4. 01 - Arduino Nano v3
  5. 01 - Arduino Nano shield (recomended, not required)
  6. 01 - Dual H-Bridge board (L298N or TB6612FNG)
  7. 01 - HC-05 Bluetooth module
  8. 02 - Red Leds
  9. 02 - White Leds
  10. 01 - Passive Buzzer
  11. 04 - 150 Ω Resistors
  12. 01 - 1.0K Ω Resistor
  13. 01 - 3.3K Ω Resistor
  14. 01 - 220 Ω Resistor
  15. 02 - 18650 batteries (3.7v - 4.2v)
  16. 01 - Battery support
  17. 01 - SG90 Servo Motor
  18. 02 - Electrolytic Capacitor (16v - 50v, 8,000 - 12,000 μF)


NOTES:

  1. TB6612FNG is a modern MOSFET driver with about 90% energy efficiency versus 40-70% for the L298N

Schematics

BluetoothRcCar_L298N.png
BluetoothRcCar_TB6612.png

You can use either a L298N (easier to build) or a TB6612 Bridge (better energy efficiency)

About Car Chassis

273486953-fc44181b-09c9-459d-bb90-3e725720ff7c.png
273486986-6d2626ba-d2ef-4a6d-9c85-598381214e7b.png

Install VS Code With Platform IO Plugin

Screenshot from 2025-05-01 00-28-11.png

Download and install PlatformIO, a plugin for Microsoft Virtual Studio Code

It is a more robust IDE compared to Arduino IDE. It also allows us to easily create our own private libraries and use a more object oriented code.

Upload the Code

The project is hosted in Github at:

https://github.com/vitorccs/bluetooth-rc-car


Download the ZIP file containing the source code at:

https://github.com/vitorccs/bluetooth-rc-car/archive/refs/heads/master.zip


Once you open the project folder at VS Code with PlatformIO, it automatically downloads and install all library dependencies - much easier than Arduino IDE and risks free of downloading incorrect source or version (!)

Customization

The PINs can be customized in the main.cpp

#include <Arduino.h>
#include <DigitalLed.h>
#include <PassiveBuzzer.h>
#include <DCMotor.h>
#include <Car.h>
#include <BluetoothJoyHandler.h>
#include <SoftwareSerial.h>
#include <ServoMotor.h>
#include <Servo.h>
#include <SerialReader.h>

#define PIN_FLED 2
#define PIN_RLED 3
#define PIN_HORN 10
#define PIN_M1_EN 5
#define PIN_M1_IN1 4
#define PIN_M1_IN2 6
#define PIN_M2_EN 11
#define PIN_M2_IN1 7
#define PIN_M2_IN2 8
#define PIN_BLUETOOTH_TX 12
#define PIN_BLUETOOTH_RX 13
#define PIN_SERVO 9
#define MIN_MOTOR_SPEED 80 // (between 0 to 255)


Fine-tuning customization can be done in the individual files like ServoMotor.h for servo motor angle

#ifndef SERVOMOTOR_H
#define SERVOMOTOR_H
#include <Arduino.h>
#include <Servo.h>

class ServoMotor
{
public:
ServoMotor(Servo &servo, uint8_t pin);
void attach();
void turn(uint16_t angle);
void turnLeft();
void turnHalfLeft();
void turnRight();
void turnHalfRight();
void reset();

private:
uint8_t pin;
Servo _servo;
uint8_t angleReset = 90;
uint8_t angleFull = 25;
uint8_t angleHalf = 15;
};

#endif


or in the DCMotor.h for changing speed parameters

#ifndef DCMOTOR_H
#define DCMOTOR_H
#include <Arduino.h>

class DCMotor
{
public:
DCMotor(uint8_t pinEn, uint8_t pinIn1, uint8_t pinIn2);
void backward(uint8_t speed = 100);
void forward(uint8_t speed = 100);
void setMinAbsSpeed(uint8_t absSpeed);
void stop();

private:
uint8_t pinEn;
uint8_t pinIn1;
uint8_t pinIn2;
uint8_t absSpeed = 0;
uint8_t maxAbsSpeed = 255;
uint8_t minAbsSpeed = 50;
uint8_t ignoreAbsSpeed = 30;

void setSpeed(uint8_t speed);
};

#endif

Bluetooth Controller

app_01.png
app_02.png

1) Download and install the free Android app called "Arduino Car"

2) Find and connect to the Bluetooth device called "HC-05" (if asked for a password, type 1234 or 0000)

3) Once installed the app, map the buttons code as shown in the picture

4) I recommend to change the controller joystick type to "Analog"

Advices

Power Supply

I recommend to use high quality 18650 batteries (3.7v - 4.2v, 2200mAh, at least 2C of discharge rate).

Most people prefer to use different power sources for Arduino (5v) and Bridge driver (7.4 - 8.4v).

I prefer to have a single power source and thus a single power switch. However, it was required to use huge Electrolytic Capacitors (around 8,000 to 12,000µF) to prevent Arduino Nano from rebooting when the 04 DC motors drains too much power. The capacitor is also useful to filter some electric noise. Note: in the video recordings above, I used 2x 18650 batteries 2600mAh (3C) and one 10,000 µF capacitor.

It is up to you!


Servo Motor

Be careful if you need to change PINs of PWM motors (PIN_M1_EN and PIN_M2_EN) and Servo (PIN_SERVO) since they cannot use the same Arduino timers.

  1. Discussion in Arduino forum
  2. Arduino timers


Resources

Fritzing file

The eletronic schematic was created in the Fritzing software and can be downloaded at

  1. BluetoothRcCar_L298N.zip
  2. BluetoothRcCar_TB6612.zip