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

Arduino UNO Bluetooth-Controlled Robotic Car with Motor Drivers and Servos

View and Edit Project In Cirkit DesignerImage of Arduino UNO Bluetooth-Controlled Robotic Car with Motor Drivers and Servos

Circuit Documentation

Summary

This circuit is designed to control a Bluetooth-enabled car using an Arduino UNO. The car is equipped with multiple motors and servos, which are controlled via an L298N motor driver. The HC-05 Bluetooth module allows for wireless communication, enabling the car to be controlled remotely. The circuit is powered by a 12V battery.

Component List

  1. Arduino UNO

    • Description: 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
  2. Motor with reducer

    • Description: DC motor with a built-in reducer.
    • Pins: 3 - 6 VCC, GND
  3. L298N DC motor driver

    • Description: Dual H-Bridge motor driver.
    • 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
  4. Battery 12V

    • Description: 12V battery for powering the circuit.
    • Pins: +, -
  5. Micro servo 9G

    • Description: Small servo motor.
    • Pins: GND, +5V, PWM
  6. HC-05 Bluetooth Module

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

Wiring Details

Arduino UNO

Motor with reducer

L298N DC motor driver

Battery 12V

Micro servo 9G

HC-05 Bluetooth Module

Code Documentation

#include <SoftwareSerial.h>

// Bluetooth module connected to pins 2 (RX) and 3 (TX)
SoftwareSerial mySerial(2, 3); 

// Motor driver pins
int Rightmotor1 = 4; 
int Rightmotor2 = 5; 
int leftmotor1 = 6; 
int leftmotor2 = 7; 
int en1 = 9; 
int en2 = 10;

// String to hold incoming Bluetooth data
String command = "";

void setup() {
  // Initialize motor pins
  pinMode(Rightmotor1, OUTPUT);
  pinMode(Rightmotor2, OUTPUT);
  pinMode(leftmotor1, OUTPUT);
  pinMode(leftmotor2, OUTPUT);
  pinMode(en1, OUTPUT);
  pinMode(en2, OUTPUT);

  // Start serial communication for debugging and Bluetooth
  Serial.begin(9600); 
  mySerial.begin(9600); 

  Serial.println("Bluetooth Car Ready!");
}

void loop() {
  if (mySerial.available()) {
    char received = mySerial.read(); // Read the single character command
    if (received == 'F') {
      moveForward(); // Move forward
    } else if (received == 'B') {
      moveBackward(); // Move backward
    } else if (received == 'L') {
      turnLeft(); // Turn left
    } else if (received == 'R') {
      turnRight(); // Turn right
    } else if (received == 'S') {
      stopMotors(); // Stop
    }
  }
}

// Movement functions
void moveForward() {
  digitalWrite(Rightmotor1, HIGH);
  digitalWrite(Rightmotor2, LOW);
  digitalWrite(leftmotor1, HIGH);
  digitalWrite(leftmotor2, LOW);
  analogWrite(en1, 200);  // Adjust speed as needed (0-255)
  analogWrite(en2, 200);
  Serial.println("Moving Forward");
}

void moveBackward() {
  digitalWrite(Rightmotor1, LOW);
  digitalWrite(Rightmotor2, HIGH);
  digitalWrite(leftmotor1, LOW);
  digitalWrite(leftmotor2, HIGH);
  analogWrite(en1, 200);
  analogWrite(en2, 200);
  Serial.println("Moving Backward");
}

void turnLeft() {
  digitalWrite(Rightmotor1, HIGH);
  digitalWrite(Rightmotor2, LOW);
  digitalWrite(leftmotor1, LOW);
  digitalWrite(leftmotor2, HIGH);
  analogWrite(en1, 150); // Reduced speed for turning
  analogWrite(en2, 150);
  Serial.println("Turning Left");
}

void turnRight() {
  digitalWrite(Rightmotor1, LOW);
  digitalWrite(Rightmotor2, HIGH);
  digitalWrite(leftmotor1, HIGH);
  digitalWrite(leftmotor2, LOW);
  analogWrite(en1, 150);
  analogWrite(en2, 150);
  Serial.println("Turning Right");
}

void stopMotors() {
  digitalWrite(Rightmotor1, LOW);
  digitalWrite(Rightmotor2, LOW);
  digitalWrite(leftmotor1, LOW);
  digitalWrite(leftmotor2, LOW);
  analogWrite(en1, 0);
  analogWrite(en2, 0);
  Serial.println("Motors Stopped");
}

This code initializes the motor driver pins and sets up serial communication for both debugging and Bluetooth. The loop function reads commands from the Bluetooth module and calls the appropriate movement functions to control the motors.