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

Arduino UNO Bluetooth-Controlled Robot with L298N Motor Driver

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

Circuit Documentation

Summary

This circuit is designed to control a robotic vehicle with two DC gearmotors for movement, which are driven by an L298N motor driver module. The Arduino UNO serves as the central microcontroller, interfacing with an HC-06 Bluetooth module for wireless communication. The system is powered by two 18650 Li-ion batteries, and a PWM motor speed controller is used to regulate the speed of additional DC gearmotors. A rocker switch is included to control the power supply to the motor driver.

Component List

Arduino UNO

Gearmotor DC Wheels (Left and Right)

PWM Motor Speed Controller

18650 Li-ion Battery x 2

Gearmotor DC / Motorreductor

L298N DC Motor Driver

HC-06

Rocker Switch

Wiring Details

Arduino UNO

Gearmotor DC Wheels (Left and Right)

PWM Motor Speed Controller

L298N DC Motor Driver

HC-06

Rocker Switch

Documented Code

int ENA = 6;
int IN1 = 13;
int IN2 = 12;
int ENB = 5;
int IN3 = 11;
int IN4 = 10;
int speedValue = 0;

void setup() {
  Serial.begin(9600);   // Start Bluetooth serial communication using default RX/TX

  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(ENB, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
}

void loop() {
  if (Serial.available()) {
    char command = Serial.read();  // Read the command from Bluetooth

    Serial.print("Received command: ");
    Serial.println(command);

    // Movement Commands
    if (command == 'F') {
      // Move Forward
      digitalWrite(IN1, HIGH);
      digitalWrite(IN2, LOW);
      digitalWrite(IN3, HIGH);
      digitalWrite(IN4, LOW);
      analogWrite(ENA, speedValue); // Control speed
      analogWrite(ENB, speedValue);

    } else if (command == 'B') {
      // Move Backward
      digitalWrite(IN1, LOW);
      digitalWrite(IN2, HIGH);
      digitalWrite(IN3, LOW);
      digitalWrite(IN4, HIGH);
      analogWrite(ENA, speedValue);
      analogWrite(ENB, speedValue);

    } else if (command == 'L') {
      // Turn Left
      digitalWrite(IN1, LOW);
      digitalWrite(IN2, HIGH);
      digitalWrite(IN3, HIGH);
      digitalWrite(IN4, LOW);
      analogWrite(ENA, speedValue);
      analogWrite(ENB, speedValue);

    } else if (command == 'R') {
      // Turn Right
      digitalWrite(IN1, HIGH);
      digitalWrite(IN2, LOW);
      digitalWrite(IN3, LOW);
      digitalWrite(IN4, HIGH);
      analogWrite(ENA, speedValue);
      analogWrite(ENB, speedValue);

    } else if (command == 'S') {
      // Stop
      digitalWrite(IN1, LOW);
      digitalWrite(IN2, LOW);
      digitalWrite(IN3, LOW);
      digitalWrite(IN4, LOW);

    } 
    // Speed control commands (0 to 9 for speed levels 0 to 100)
    else if (command >= '0' && command <= '9') {
      speedValue = map(command - '0', 0, 9, 0, 255);
      Serial.print("Speed set to: ");
      Serial.println(speedValue);
    }
  }
}

This code is designed to be uploaded to the Arduino UNO microcontroller. It sets up the necessary pins for motor control and listens for Bluetooth commands to control the movement and speed of the motors. The commands 'F', 'B', 'L', 'R', and 'S' correspond to forward, backward, left, right, and stop movements, respectively. Speed is adjusted with numeric commands '0' to '9'.