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

Bluetooth-Controlled Arduino UNO Robotic Car with L298N Motor Driver

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

Circuit Documentation

Summary of the Circuit

This circuit is designed to control a car using Bluetooth technology. It consists of an Arduino UNO microcontroller that interfaces with a Bluetooth HC-06 module for wireless communication and an L298N DC motor driver to control two hobby motors. The motors are powered by 9V batteries connected through a 2.1mm Barrel Jack with Terminal Block. The Arduino UNO receives commands via Bluetooth and drives the motors to move the car forward, backward, turn left, turn right, or stop.

Component List

Arduino UNO

  • 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.

Motor Amarillo Motorreductor Hobby (x2)

  • A yellow hobby gear motor
  • Operates on a voltage suitable for interfacing with the L298N motor driver.

Bluetooth HC-06

  • A wireless Bluetooth transceiver module
  • Allows serial communication over Bluetooth.

Battery 9V (x2)

  • Standard 9V batteries
  • Provide power to the motor driver and, indirectly, to the motors.

L298N DC Motor Driver

  • A dual H-bridge motor driver
  • Capable of driving two DC motors or one stepper motor.

2.1mm Barrel Jack with Terminal Block

  • A connector for attaching external power sources
  • Used to connect the 9V batteries to the circuit.

Wiring Details

Arduino UNO

  • 5V connected to Bluetooth HC-06 VCC
  • GND connected to Bluetooth HC-06 GND
  • 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
  • D1 (TX) connected to Bluetooth HC-06 RXD
  • D0 (RX) connected to Bluetooth HC-06 TXD

Motor Amarillo Motorreductor Hobby

  • vcc of the first motor connected to L298N DC motor driver OUT2
  • GND of the first motor connected to L298N DC motor driver OUT1
  • vcc of the second motor connected to L298N DC motor driver OUT4
  • GND of the second motor connected to L298N DC motor driver OUT3

Bluetooth HC-06

  • VCC connected to Arduino UNO 5V
  • GND connected to Arduino UNO GND
  • TXD connected to Arduino UNO D0 (RX)
  • RXD connected to Arduino UNO D1 (TX)

Battery 9V

  • VCC of the first battery connected to L298N DC motor driver 12V and 2.1mm Barrel Jack POS
  • GND of the first battery connected to 2.1mm Barrel Jack NEG
  • VCC of the second battery connected to L298N DC motor driver 12V
  • GND of the second battery connected to L298N DC motor driver GND

L298N DC Motor Driver

  • IN1 connected to Arduino UNO D7
  • IN2 connected to Arduino UNO D6
  • IN3 connected to Arduino UNO D5
  • IN4 connected to Arduino UNO D4
  • OUT1 connected to the first motor GND
  • OUT2 connected to the first motor vcc
  • OUT3 connected to the second motor GND
  • OUT4 connected to the second motor vcc
  • 12V connected to both 9V batteries VCC
  • GND connected to the second 9V battery GND

2.1mm Barrel Jack with Terminal Block

  • POS connected to the first 9V battery VCC
  • NEG connected to the first 9V battery GND

Documented Code

/*
 * Arduino Sketch for controlling a car using Bluetooth technology.
 * This code reads commands from the Serial input (Bluetooth module) and
 * controls the car's movement accordingly. The car can move forward,
 * backward, turn left, turn right, and stop based on the received commands.
 */

int Input_Pin_4 = 4; // Connected to L298N IN4
int Input_Pin_3 = 5; // Connected to L298N IN3
int Input_Pin_2 = 6; // Connected to L298N IN2
int Input_Pin_1 = 7; // Connected to L298N IN1
char Value;

void setup() {
  pinMode(Input_Pin_4, OUTPUT);  // Digital pin 4
  pinMode(Input_Pin_3, OUTPUT);  // Digital pin 5
  pinMode(Input_Pin_2, OUTPUT);  // Digital pin 6
  pinMode(Input_Pin_1, OUTPUT);  // Digital pin 7
  Serial.begin(9600);
}

void loop() {
  while (Serial.available() > 0) {
    Value = Serial.read();
    Serial.println(Value);
  }
  if (Value == 'F') {
    // Move Forward
    digitalWrite(Input_Pin_1, HIGH);
    digitalWrite(Input_Pin_2, LOW);
    digitalWrite(Input_Pin_3, HIGH);
    digitalWrite(Input_Pin_4, LOW);
  } else if (Value == 'B') {
    // Move Backward
    digitalWrite(Input_Pin_1, LOW);
    digitalWrite(Input_Pin_2, HIGH);
    digitalWrite(Input_Pin_3, LOW);
    digitalWrite(Input_Pin_4, HIGH);
  } else if (Value == 'L') {
    // Turn Left
    digitalWrite(Input_Pin_1, LOW);
    digitalWrite(Input_Pin_2, LOW);
    digitalWrite(Input_Pin_3, HIGH);
    digitalWrite(Input_Pin_4, LOW);
  } else if (Value == 'R') {
    // Turn Right
    digitalWrite(Input_Pin_1, HIGH);
    digitalWrite(Input_Pin_2, LOW);
    digitalWrite(Input_Pin_3, LOW);
    digitalWrite(Input_Pin_4, LOW);
  } else if (Value == 'S') {
    // Stop
    digitalWrite(Input_Pin_1, LOW);
    digitalWrite(Input_Pin_2, LOW);
    digitalWrite(Input_Pin_3, LOW);
    digitalWrite(Input_Pin_4, LOW);
  }
}

This code is designed to be uploaded to the Arduino UNO microcontroller. It sets up the digital pins connected to the L298N motor driver as outputs and initializes serial communication for receiving Bluetooth commands. The loop function reads the incoming serial data and controls the motor driver to move the car based on the received command character.