Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Bluetooth-Controlled RC Car with L298N Motor Driver

View and Edit Project In Cirkit DesignerImage of Arduino UNO Bluetooth-Controlled RC Car with L298N Motor Driver

Circuit Documentation

Summary of the Circuit

This circuit is designed to control a front-wheel-drive RC car using voice commands received through an HC-05 Bluetooth module. The Arduino UNO microcontroller processes the commands and controls the L298N motor driver, which in turn drives two hobby motors. The circuit is powered by a 9V battery, and the Arduino UNO regulates the voltage for the HC-05 Bluetooth module.

Component List

Arduino UNO

L298N DC Motor Driver

HC-05 Bluetooth Module

Motor Amarillo Motorreductor Hobby (x2)

9V Battery

Wiring Details

Arduino UNO

L298N DC Motor Driver

HC-05 Bluetooth Module

Motor Amarillo Motorreductor Hobby (First Motor)

Motor Amarillo Motorreductor Hobby (Second Motor)

9V Battery

Documented Code

/*
 * Arduino Sketch for Front-Wheel Drive RC Car with Voice Recognition
 *
 * This code controls a front-wheel-drive RC car using voice commands received
 * via the HC-05 Bluetooth module. The Arduino UNO processes the commands and
 * controls the L298N motor driver to drive the motors accordingly.
 */

// Pin definitions
const int IN1 = 8;
const int IN2 = 9;
const int IN3 = 10;
const int IN4 = 11;
const int ENA = 5;
const int ENB = 6;
const int BT_RX = 0;
const int BT_TX = 1;

void setup() {
  // Initialize motor control pins
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
  pinMode(ENA, OUTPUT);
  pinMode(ENB, OUTPUT);
  // Initialize Bluetooth communication
  Serial.begin(9600);
}

void loop() {
  // Check if data is available from Bluetooth
  if (Serial.available() > 0) {
    char command = Serial.read();
    // Process the received command
    switch (command) {
      case 'F':
        moveForward();
        break;
      case 'B':
        moveBackward();
        break;
      case 'L':
        turnLeft();
        break;
      case 'R':
        turnRight();
        break;
      case 'S':
        stopCar();
        break;
    }
  }
}

void moveForward() {
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
  analogWrite(ENA, 255);
  analogWrite(ENB, 255);
}

void moveBackward() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
  analogWrite(ENA, 255);
  analogWrite(ENB, 255);
}

void turnLeft() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
  analogWrite(ENA, 255);
  analogWrite(ENB, 255);
}

void turnRight() {
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
  analogWrite(ENA, 255);
  analogWrite(ENB, 255);
}

void stopCar() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
  analogWrite(ENA, 0);
  analogWrite(ENB, 0);
}

This code is responsible for interpreting the commands received from the HC-05 Bluetooth module and controlling the motors through the L298N motor driver. The commands are single characters that represent different actions for the RC car: 'F' for forward, 'B' for backward, 'L' for left turn, 'R' for right turn, and 'S' for stop. The moveForward, moveBackward, turnLeft, turnRight, and stopCar functions are used to control the motor driver's inputs and enable pins to achieve the desired motion.