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

Arduino-Controlled Bluetooth Robot with Dual Motor Driver

Image of Arduino-Controlled Bluetooth Robot with Dual Motor Driver

Circuit Documentation

Summary

This circuit is designed to control a pair of DC motors using an L298N motor driver module, with an Arduino UNO as the central microcontroller. The system also includes an HC-05 Bluetooth module for wireless communication, allowing remote control of the motors. The motors are powered by a 12V battery, which also supplies power to the L298N module. The Arduino UNO is powered by the 5V output from the L298N module. The HC-05 Bluetooth module interfaces with the Arduino UNO for receiving commands to control the motors' direction and speed.

Component List

HC-05 Bluetooth Module

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

Motor Amarillo Motorreductor Hobby (x4)

  • Description: A yellow DC gear motor for hobby projects.
  • Pins: VCC, GND

L298N DC Motor Driver

  • Description: A module for driving up to two 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

Battery 12V (x2)

  • Description: A 12V battery to power the motors and motor driver.
  • Pins: +, -

Arduino UNO

  • Description: A microcontroller board based on the ATmega328P.
  • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0

Wiring Details

HC-05 Bluetooth Module

  • VCC connected to Arduino UNO 5V
  • GND connected to Arduino UNO GND
  • TXD connected to Arduino UNO D0
  • RXD connected to Arduino UNO D1

Motor Amarillo Motorreductor Hobby

  • Four motors with their VCC and GND pins connected to L298N DC motor driver OUT1, OUT2, OUT3, and OUT4 respectively.

L298N DC Motor Driver

  • 12V connected to 12V battery +
  • GND connected to 12V battery - and Arduino UNO GND
  • 5V connected to Arduino UNO 5V
  • IN1 connected to Arduino UNO D7
  • IN2 connected to Arduino UNO D6
  • IN3 connected to Arduino UNO D5
  • IN4 connected to Arduino UNO D4

Arduino UNO

  • 5V connected to L298N DC motor driver 5V and HC-05 Bluetooth Module VCC
  • GND connected to L298N DC motor driver GND and HC-05 Bluetooth Module GND
  • D0 connected to HC-05 Bluetooth Module TXD
  • D1 connected to HC-05 Bluetooth Module RXD
  • D7 connected to L298N DC motor driver IN1
  • D6 connected to L298N DC motor driver IN2
  • D5 connected to L298N DC motor driver IN3
  • D4 connected to L298N DC motor driver IN4

Documented Code

#include <SoftwareSerial.h>

// Define motor pins
const int motor1Pin1 = 2;
const int motor1Pin2 = 3;
const int motor2Pin1 = 4;
const int motor2Pin2 = 5;

// Define Bluetooth module pins
const int rxPin = 10;
const int txPin = 11;

// Create a SoftwareSerial object for Bluetooth communication
SoftwareSerial bluetooth(rxPin, txPin);

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

  // Set motor pins as output
  pinMode(motor1Pin1, OUTPUT);
  pinMode(motor1Pin2, OUTPUT);
  pinMode(motor2Pin1, OUTPUT);
  pinMode(motor2Pin2, OUTPUT);
}

void loop() {
  if (bluetooth.available() > 0) {
    char command = bluetooth.read();

    switch (command) {
      case 'F': // Forward
        forward();
        break;
      case 'B': // Backward
        backward();
        break;
      case 'L': // Left
        left();
        break;
      case 'R': // Right
        right();
        break;
      case 'S': // Stop
        stop();
        break;
    }
  }
}

// Function to move the car forward
void forward() {
  digitalWrite(motor1Pin1, HIGH);
  digitalWrite(motor1Pin2, LOW);
  digitalWrite(motor2Pin1, HIGH);
  digitalWrite(motor2Pin2, LOW);
}

// Function to move the car backward
void backward() {
  digitalWrite(motor1Pin1, LOW);
  digitalWrite(motor1Pin2, HIGH);
  digitalWrite(motor2Pin1, LOW);
  digitalWrite(motor2Pin2, HIGH);
}

// Function to turn the car left
void left() {
  digitalWrite(motor1Pin1, HIGH);
  digitalWrite(motor1Pin2, LOW);
  digitalWrite(motor2Pin1, LOW);
  digitalWrite(motor2Pin2, HIGH);
}

// Function to turn the car right
void right() {
  digitalWrite(motor1Pin1, LOW);
  digitalWrite(motor1Pin2, HIGH);
  digitalWrite(motor2Pin1, HIGH);
  digitalWrite(motor2Pin2, LOW);
}

// Function to stop the car
void stop() {
  digitalWrite(motor1Pin1, LOW);
  digitalWrite(motor1Pin2, LOW);
  digitalWrite(motor2Pin1, LOW);
  digitalWrite(motor2Pin2, LOW);
}

This code is designed to be uploaded to the Arduino UNO microcontroller. It initializes the Bluetooth communication and sets up the motor control pins. The loop function listens for commands from the Bluetooth module and calls the appropriate function to control the motors. The functions forward(), backward(), left(), right(), and stop() control the motors' movements.