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

Arduino Nano Bluetooth-Controlled Car with L298N Motor Driver

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

Circuit Documentation

Summary

This document provides a detailed overview of a hand gesture-controlled car circuit. The circuit uses an Arduino Nano microcontroller to interface with an HC-05 Bluetooth module for receiving commands and an L298N motor driver to control four DC motors. The power is supplied by a 18650 Li-Ion battery.

Component List

  1. Arduino Nano

    • Description: A compact microcontroller board based on the ATmega328P.
    • Pins: D1/TX, D0/RX, RESET, GND, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11/MOSI, D12/MISO, VIN, 5V, A7, A6, A5, A4, A3, A2, A1, A0, AREF, 3V3, D13/SCK
  2. L298N DC Motor Driver

    • Description: A dual H-bridge motor driver that allows control of the speed and direction of 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
  3. HC-05 Bluetooth Module

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

    • Description: A simple DC motor used for driving the car.
    • Pins: pin 1, pin 2
  5. 18650 Li-Ion Battery

    • Description: A rechargeable lithium-ion battery.
    • Pins: Positive, Negative

Wiring Details

Arduino Nano

L298N DC Motor Driver

HC-05 Bluetooth Module

DC Motors

18650 Li-Ion Battery

Code Documentation

/*
 * Arduino Sketch for Hand Gesture Controlled Car (Receiver End)
 * This code interfaces with an HC-05 Bluetooth module to receive commands
 * and controls four DC motors via an L298N motor driver.
 */

// Pin definitions for L298N motor driver
const int IN1 = 4;
const int IN2 = 5;
const int IN3 = 6;
const int IN4 = 7;

// Bluetooth module serial communication
const int bluetoothTx = 1; // TX pin of Arduino
const int bluetoothRx = 0; // RX pin of Arduino

void setup() {
  // Initialize motor control pins as outputs
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);

  // Initialize serial communication for Bluetooth module
  Serial.begin(9600);
}

void loop() {
  // Check if data is available from Bluetooth module
  if (Serial.available() > 0) {
    char command = Serial.read();
    // Control motors based on received command
    switch (command) {
      case 'F': // Move forward
        digitalWrite(IN1, HIGH);
        digitalWrite(IN2, LOW);
        digitalWrite(IN3, HIGH);
        digitalWrite(IN4, LOW);
        break;
      case 'B': // Move backward
        digitalWrite(IN1, LOW);
        digitalWrite(IN2, HIGH);
        digitalWrite(IN3, LOW);
        digitalWrite(IN4, HIGH);
        break;
      case 'L': // Turn left
        digitalWrite(IN1, LOW);
        digitalWrite(IN2, HIGH);
        digitalWrite(IN3, HIGH);
        digitalWrite(IN4, LOW);
        break;
      case 'R': // Turn right
        digitalWrite(IN1, HIGH);
        digitalWrite(IN2, LOW);
        digitalWrite(IN3, LOW);
        digitalWrite(IN4, HIGH);
        break;
      case 'S': // Stop
        digitalWrite(IN1, LOW);
        digitalWrite(IN2, LOW);
        digitalWrite(IN3, LOW);
        digitalWrite(IN4, LOW);
        break;
    }
  }
}

This code initializes the motor control pins and sets up serial communication with the HC-05 Bluetooth module. In the main loop, it reads commands from the Bluetooth module and controls the motors accordingly to move the car forward, backward, left, right, or stop.