Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO Bluetooth-Controlled RC Car with L298N Motor Driver

Image of Arduino UNO Bluetooth-Controlled RC Car with L298N Motor Driver

Circuit Documentation

Summary

This circuit is designed to control a remote-controlled (RC) car using an Arduino UNO microcontroller, an HC-05 Bluetooth module for wireless communication, and an L298N motor driver to control four DC motors. The system is powered by a 2x 18650 battery pack, and a rocker switch is used to control the power supply to the circuit. The Arduino UNO receives commands via Bluetooth and controls the motors accordingly to move the car forward, backward, turn left, right, or stop.

Component List

HC-05 Bluetooth Module

  • Description: A Bluetooth module used for wireless communication.
  • Pins: Key, VCC, GND, TXD, RXD, State

L298N DC Motor Driver

  • Description: A motor driver module used to control the direction and speed of DC motors.
  • Pins: OUT1, OUT2, 12V, GND, 5V, OUT3, OUT4, 5V-ENA-JMP-I, 5V-ENA-JMP-O, +5V-J1, +5V-J2, ENA, IN1, IN2, IN3, IN4, ENB

2x 18650 Battery Pack

  • Description: A battery pack providing the power source for the circuit.
  • Pins: VCC, GND

Arduino UNO

  • Description: A microcontroller board based on the ATmega328P.
  • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5, SCL, SDA, AREF, D0-D13

Rocker Switch

  • Description: A switch used to control the power supply to the circuit.
  • Pins: 1, 2

DC Motors

  • Description: Motors used to drive the wheels of the RC car.
  • Pins: Pin 1, Pin 2

Wiring Details

HC-05 Bluetooth Module

  • VCC connected to Arduino UNO Vin
  • GND connected to Arduino UNO GND
  • TXD connected to Arduino UNO D11
  • RXD connected to Arduino UNO D10

L298N DC Motor Driver

  • OUT1 connected to two DC Motors (pin 2)
  • OUT2 connected to the same two DC Motors (pin 1)
  • OUT3 connected to another two DC Motors (pin 2)
  • OUT4 connected to the same two DC Motors (pin 1)
  • 12V connected to Rocker Switch pin 2
  • GND connected to Arduino UNO GND and 2x 18650 Battery Pack GND
  • 5V connected to Arduino UNO 5V
  • IN1 connected to Arduino UNO D2
  • IN2 connected to Arduino UNO D3
  • IN3 connected to Arduino UNO D4
  • IN4 connected to Arduino UNO D5

2x 18650 Battery Pack

  • VCC connected to Rocker Switch pin 1
  • GND connected to L298N DC Motor Driver GND and Arduino UNO GND

Rocker Switch

  • Pin 1 connected to 2x 18650 Battery Pack VCC
  • Pin 2 connected to L298N DC Motor Driver 12V

DC Motors

  • Four DC Motors connected to L298N DC Motor Driver OUT1, OUT2, OUT3, and OUT4

Documented Code

/*
 * Arduino-based Bluetooth Controlled RC Car
 * This code allows an Arduino UNO to control an RC car using an HC-05 Bluetooth
 * module and an L298N motor driver. The car can be controlled via a Bluetooth
 * connection from a smartphone or other Bluetooth-enabled device.
 */

#include <SoftwareSerial.h>

// Bluetooth module pins
const int bluetoothTx = 11;
const int bluetoothRx = 10;

// Motor driver pins
const int motorIn1 = 2;
const int motorIn2 = 3;
const int motorIn3 = 4;
const int motorIn4 = 5;

// Create a software serial port for the Bluetooth module
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup() {
  // Initialize serial communication
  Serial.begin(9600);
  bluetooth.begin(9600);

  // Initialize motor driver pins as outputs
  pinMode(motorIn1, OUTPUT);
  pinMode(motorIn2, OUTPUT);
  pinMode(motorIn3, OUTPUT);
  pinMode(motorIn4, OUTPUT);
}

void loop() {
  // Check if data is available from the Bluetooth module
  if (bluetooth.available()) {
    char command = bluetooth.read();
    Serial.println(command);

    // Control the motors based on the received command
    switch (command) {
      case 'F': // Move forward
        digitalWrite(motorIn1, HIGH);
        digitalWrite(motorIn2, LOW);
        digitalWrite(motorIn3, HIGH);
        digitalWrite(motorIn4, LOW);
        break;
      case 'B': // Move backward
        digitalWrite(motorIn1, LOW);
        digitalWrite(motorIn2, HIGH);
        digitalWrite(motorIn3, LOW);
        digitalWrite(motorIn4, HIGH);
        break;
      case 'L': // Turn left
        digitalWrite(motorIn1, LOW);
        digitalWrite(motorIn2, HIGH);
        digitalWrite(motorIn3, HIGH);
        digitalWrite(motorIn4, LOW);
        break;
      case 'R': // Turn right
        digitalWrite(motorIn1, HIGH);
        digitalWrite(motorIn2, LOW);
        digitalWrite(motorIn3, LOW);
        digitalWrite(motorIn4, HIGH);
        break;
      case 'S': // Stop
        digitalWrite(motorIn1, LOW);
        digitalWrite(motorIn2, LOW);
        digitalWrite(motorIn3, LOW);
        digitalWrite(motorIn4, LOW);
        break;
    }
  }
}

This code is designed to be uploaded to the Arduino UNO microcontroller. It sets up a software serial connection to communicate with the HC-05 Bluetooth module and configures the digital pins connected to the L298N motor driver as outputs. The loop function listens for commands from the Bluetooth module and controls the motors accordingly.