Arduino UNO Bluetooth-Controlled Robotic Car with L298N Motor Driver and 18650 Li-Ion Battery
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This document provides a detailed overview of a circuit designed to control multiple motors using an Arduino UNO, an L298N DC motor driver, and an HC-05 Bluetooth module. The circuit is powered by a 18650 Li-Ion battery. The Arduino UNO receives commands via Bluetooth and controls the motors accordingly.
Component List
Motor with reducer
- Description: A motor with an integrated reducer to control speed and torque.
- Pins: 3 - 6 VCC, GND
Arduino UNO
- Description: A 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
L298N DC motor driver
- Description: A dual H-Bridge motor driver module.
- 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
18650 Li-Ion
- Description: A rechargeable lithium-ion battery.
- Pins: Positive, Negative
HC-05 Bluetooth Module
- Description: A Bluetooth module for wireless communication.
- Pins: Key, VCC, TXD, RXD, State, GND
Wiring Details
Motor with reducer
Motor 1:
- 3 - 6 VCC: Connected to OUT4 of L298N DC motor driver
- GND: Connected to OUT4 of L298N DC motor driver
Motor 2:
- 3 - 6 VCC: Connected to OUT3 of L298N DC motor driver
- GND: Connected to OUT3 of L298N DC motor driver
Motor 3:
- 3 - 6 VCC: Connected to OUT1 of L298N DC motor driver
- GND: Connected to OUT2 of L298N DC motor driver
Motor 4:
- 3 - 6 VCC: Connected to OUT1 of L298N DC motor driver
- GND: Connected to OUT2 of L298N DC motor driver
Arduino UNO
- 5V: Connected to VCC of HC-05 Bluetooth Module
- GND: Connected to GND of HC-05 Bluetooth Module, GND of L298N DC motor driver, and Negative of 18650 Li-Ion battery
- Vin: Connected to Positive of 18650 Li-Ion battery
- D7: Connected to IN4 of L298N DC motor driver
- D6: Connected to IN3 of L298N DC motor driver
- D5: Connected to IN2 of L298N DC motor driver
- D4: Connected to IN1 of L298N DC motor driver
- D1: Connected to RXD of HC-05 Bluetooth Module
- D0: Connected to TXD of HC-05 Bluetooth Module
L298N DC motor driver
- GND: Connected to GND of Arduino UNO and Negative of 18650 Li-Ion battery
- 12V: Connected to Positive of 18650 Li-Ion battery
- OUT4: Connected to 3 - 6 VCC and GND of Motor 1
- OUT3: Connected to 3 - 6 VCC and GND of Motor 2
- OUT1: Connected to 3 - 6 VCC of Motor 3 and Motor 4
- OUT2: Connected to GND of Motor 3 and Motor 4
- IN4: Connected to D7 of Arduino UNO
- IN3: Connected to D6 of Arduino UNO
- IN2: Connected to D5 of Arduino UNO
- IN1: Connected to D4 of Arduino UNO
18650 Li-Ion
- Positive: Connected to 12V of L298N DC motor driver and Vin of Arduino UNO
- Negative: Connected to GND of L298N DC motor driver and GND of Arduino UNO
HC-05 Bluetooth Module
- VCC: Connected to 5V of Arduino UNO
- GND: Connected to GND of Arduino UNO
- RXD: Connected to D1 of Arduino UNO
- TXD: Connected to D0 of Arduino UNO
Documented Code
char data; // Variable to store received data
void setup() {
Serial.begin(9600); // Start serial communication at 9600 baud rate
// Set motor control pins as output
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
data = Serial.read(); // Read received data
// Control motor movement based on received data
switch (data) {
case 'F': // Move Forward
digitalWrite(7, HIGH);
digitalWrite(6, LOW);
digitalWrite(5, HIGH);
digitalWrite(4, LOW);
break;
case 'B': // Move Backward
digitalWrite(7, LOW);
digitalWrite(6, HIGH);
digitalWrite(5, LOW);
digitalWrite(4, HIGH);
break;
case 'R': // Turn Right
digitalWrite(7, LOW);
digitalWrite(6, HIGH);
digitalWrite(5, HIGH);
digitalWrite(4, LOW);
break;
case 'L': // Turn Left
digitalWrite(7, HIGH);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(4, HIGH);
break;
case 'S': // Stop
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(4, LOW);
break;
}
}
}
This code initializes the serial communication and sets the motor control pins as outputs. It reads data from the Bluetooth module and controls the motors based on the received commands.