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 HC-05 Bluetooth module enables wireless communication with the Arduino, allowing for remote control of the car's movements.

Component List

Arduino UNO

L298N DC Motor Driver

HC-05 Bluetooth Module

Motor Amarillo Motorreductor Hobby (x2)

Wiring Details

Arduino UNO

L298N DC Motor Driver

HC-05 Bluetooth Module

Motor Amarillo Motorreductor Hobby

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 setting up the Arduino UNO to receive Bluetooth commands and control the motors through the L298N motor driver. It defines the necessary pin configurations and contains functions to move the car forward, backward, turn left, turn right, and stop the car based on the received Bluetooth commands.