Arduino UNO Bluetooth-Controlled Robotic Car with Motor Driver and Relay
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to control a set of motors and a relay using an Arduino UNO microcontroller. The circuit includes an L298N DC motor driver for motor control, an HC-05 Bluetooth module for wireless communication, and a 5V relay for switching operations. The Arduino UNO is programmed to receive commands via Bluetooth and control the motors and relay accordingly.
Component List
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
L298N DC Motor Driver
- Description: Dual H-Bridge motor driver for controlling 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
HC-05 Bluetooth Module
- Description: Bluetooth module for wireless communication.
- Pins: Key, VCC, GND, TXD, RXD, State
5V Relay
- Description: Relay module for switching operations.
- Pins: Normally Open, Common terminal, Normally Closed, In, GND, VCC
Set Battery (7V)
- Description: Power source for the circuit.
- Pins: +, -
Motor with Reducer
- Description: DC motor with a gear reducer.
- Pins: 3 - 6 VCC, GND
DC 12V Gear Motor
- Description: High-torque DC motor.
- Pins: None
Wiring Details
Arduino UNO
- 3.3V connected to 5V Relay VCC
- 5V connected to HC-05 Bluetooth Module VCC
- GND connected to L298N DC Motor Driver GND, Set Battery (7V) -, 5V Relay GND, and HC-05 Bluetooth Module GND
- Vin connected to L298N DC Motor Driver 5V
- D12 connected to 5V Relay In
- D11 connected to L298N DC Motor Driver IN1
- D10 connected to L298N DC Motor Driver IN2
- D6 connected to L298N DC Motor Driver IN3
- D5 connected to L298N DC Motor Driver IN4
- D1 connected to HC-05 Bluetooth Module RXD
- D0 connected to HC-05 Bluetooth Module TXD
L298N DC Motor Driver
- GND connected to Arduino UNO GND
- 5V connected to Arduino UNO Vin
- IN1 connected to Arduino UNO D11
- IN2 connected to Arduino UNO D10
- IN3 connected to Arduino UNO D6
- IN4 connected to Arduino UNO D5
- OUT1 connected to Motor with Reducer 3 - 6 VCC
- OUT2 connected to Motor with Reducer GND
- OUT3 connected to Motor with Reducer 3 - 6 VCC
- OUT4 connected to Motor with Reducer GND
- 12V connected to Set Battery (7V) +
- 5V-ENA-JMP-I connected to 5V-ENA-JMP-O
- ENA connected to +5V-J1
- +5V-J2 connected to ENB
HC-05 Bluetooth Module
- VCC connected to Arduino UNO 5V
- GND connected to Arduino UNO GND
- TXD connected to Arduino UNO D0
- RXD connected to Arduino UNO D1
5V Relay
- VCC connected to Arduino UNO 3.3V
- GND connected to Arduino UNO GND
- In connected to Arduino UNO D12
- Common terminal connected to DC 12V Gear Motor
- Normally Closed connected to Set Battery (7V) +
Set Battery (7V)
- + connected to L298N DC Motor Driver 12V and 5V Relay Normally Closed
- - connected to Arduino UNO GND and DC 12V Gear Motor
Motor with Reducer
- 3 - 6 VCC connected to L298N DC Motor Driver OUT1 and OUT3
- GND connected to L298N DC Motor Driver OUT2 and OUT4
DC 12V Gear Motor
- Connected to 5V Relay Common terminal and Set Battery (7V) -
Documented Code
char t;
const int relayPin = 8; // Connect the relay to pin 8
void setup() {
pinMode(13, OUTPUT); // left motors forward
pinMode(12, OUTPUT); // left motors reverse
pinMode(11, OUTPUT); // right motors forward
pinMode(10, OUTPUT); // right motors reverse
pinMode(relayPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
if (Serial.available()) {
t = Serial.read();
Serial.println(t);
}
if (t == 'F') { // move forward (all motors rotate in forward direction)
digitalWrite(13, HIGH);
digitalWrite(11, HIGH);
} else if (t == 'B') { // move reverse (all motors rotate in reverse direction)
digitalWrite(12, HIGH);
digitalWrite(10, HIGH);
} else if (t == 'L') { // turn right (left side motors rotate in forward direction, right side motors don't rotate)
digitalWrite(11, HIGH);
} else if (t == 'R') { // turn left (right side motors rotate in forward direction, left side motors don't rotate)
digitalWrite(13, HIGH);
} else if (t == 'W') { // turn relay on
digitalWrite(relayPin, HIGH);
} else if (t == 'w') { // turn relay off
digitalWrite(relayPin, LOW);
} else if (t == 'S') { // STOP (all motors stop)
digitalWrite(13, LOW);
digitalWrite(12, LOW);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
}
delay(100);
}
This code is designed to control the motors and relay based on commands received via Bluetooth. The commands 'F', 'B', 'L', 'R', 'W', 'w', and 'S' control the forward, backward, left, right movements, relay on, relay off, and stop actions, respectively.