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

Arduino-Controlled Bluetooth DC Motor Driver System

Image of Arduino-Controlled Bluetooth DC Motor Driver System

Circuit Documentation

Summary

This circuit is designed to control a pair of DC motors using an Arduino UNO microcontroller and an L298N DC motor driver. The system is capable of receiving commands via a Bluetooth HC-06 module to drive the motors forward or backward. A resistor is included in the circuit to interface between the Arduino and the Bluetooth module. The entire system is powered by a 12V battery.

Component List

Resistor

  • Description: A passive two-terminal electrical component that implements electrical resistance as a circuit element.
  • Properties: 200 Ohms resistance.

DC Motor (x2)

  • Description: An electric motor that runs on direct current (DC) electricity.

Arduino UNO

  • Description: A microcontroller board based on the ATmega328P. It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.

12V Battery

  • Description: A power source that provides 12 volts of direct current.

L298N DC Motor Driver

  • Description: A motor driver module that can control up to two DC motors at a constant current of 2A (max 3A).

Bluetooth HC-06

  • Description: A Bluetooth module that allows for serial communication over Bluetooth.

Mobile Phone

  • Description: A device that can communicate with the Bluetooth module to send control commands.

Wiring Details

Resistor

  • Connected between the Arduino UNO's D11 pin and the Bluetooth HC-06's RXD pin.

DC Motor 1

  • Connected to the L298N motor driver's OUT1 and OUT2.

DC Motor 2

  • Connected to the L298N motor driver's OUT3 and OUT4.

Arduino UNO

  • 5V pin connected to the Bluetooth HC-06's VCC pin.
  • GND pin connected to the Bluetooth HC-06's GND pin.
  • Vin pin connected to the L298N motor driver's 5V pin.
  • D13 pin connected to the Bluetooth HC-06's TXD pin.
  • D8, D6, D4, and D2 pins connected to the L298N motor driver's IN4, IN3, IN2, and IN1 respectively.

12V Battery

  • "+" pin connected to the L298N motor driver's 12V pin.
  • "-" pin connected to the L298N motor driver's GND pin.

L298N DC Motor Driver

  • 5V pin connected to the Arduino UNO's Vin pin.
  • GND pin connected to the 12V Battery's "-" pin.
  • 12V pin connected to the 12V Battery's "+" pin.
  • IN1, IN2, IN3, and IN4 pins connected to the Arduino UNO's D2, D4, D6, and D8 pins respectively.
  • OUT1, OUT2, OUT3, and OUT4 pins connected to the DC Motors.

Bluetooth HC-06

  • VCC pin connected to the Arduino UNO's 5V pin.
  • GND pin connected to the Arduino UNO's GND pin.
  • TXD pin connected to the Arduino UNO's D13 pin.
  • RXD pin connected through a resistor to the Arduino UNO's D11 pin.

Documented Code

#include <SoftwareSerial.h>;
SoftwareSerial BTSerial(3,4); // RX, TX
char incomingData;
int inn1 = 2; // Motor driver input 1
int inn2 = 4; // Motor driver input 2
int inn3 = 6; // Motor driver input 3
int inn4 = 8; // Motor driver input 4

void setup() {
  // Initialize serial communications:
  Serial.begin(9600);
  BTSerial.begin(9600);

  // Set motor driver pins as outputs:
  pinMode(inn1, OUTPUT);
  pinMode(inn2, OUTPUT);
  pinMode(inn3, OUTPUT);
  pinMode(inn4, OUTPUT);
}

void loop() {
  // Check for Bluetooth data:
  if(BTSerial.available() > 0){
    incomingData = BTSerial.read();
    if(incomingData == 'F'){ // Forward command
        Forward();
    }else if(incomingData == 'B'){ // Backward command
        Backward();
    }else{
        Stop(); // Stop command
    }
  }
}

void Forward(){
  digitalWrite(inn1, HIGH);
  digitalWrite(inn3, HIGH);
  digitalWrite(inn2, LOW);
  digitalWrite(inn4, LOW);
}

void Backward(){
  digitalWrite(inn1, LOW);
  digitalWrite(inn3, LOW);
  digitalWrite(inn2, HIGH);
  digitalWrite(inn4, HIGH);
}

void Stop(){
  digitalWrite(inn1, LOW);
  digitalWrite(inn3, LOW);
  digitalWrite(inn2, LOW);
  digitalWrite(inn4, LOW);
}

Note: The code provided assumes that the incoming data from the Bluetooth module is a single character representing the command ('F' for Forward, 'B' for Backward, and any other character for Stop). The motor driver inputs are controlled accordingly to drive the motors in the desired direction.