Arduino Uno R3 Controlled Bluetooth Robot with L298N Motor Driver and LED Indicator
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to control a set of DC motors using an Arduino Uno R3 microcontroller and an L298N DC motor driver. The circuit includes a Bluetooth module (HC-05) for wireless communication and an LED indicator. The Arduino Uno R3 is programmed to interpret serial commands to control the motion of the motors (forward, reverse, left, right, stop) and to toggle the LED state. The motors are powered by a 4 x AAA battery mount, and the Arduino is responsible for driving the motors through the L298N motor driver.
Component List
Arduino Uno R3
- Microcontroller board based on the ATmega328P
- Features digital I/O pins, analog input pins, and various power options
L298N DC Motor Driver
- A dual H-bridge motor driver capable of driving two DC motors or one stepper motor
- Provides an external power supply option for motors
DC Motors (4x)
- Standard DC motors for driving mechanical loads
- Each motor has two pins: one for power and one for ground
HC-05 Bluetooth Module
- A wireless communication module that allows for serial communication via Bluetooth
- Features pins for power, ground, transmit (TX), receive (RX), and state
LED: Two Pin (red)
- A simple red LED with an anode and cathode for indication purposes
4 x AAA Battery Mount
- A battery holder for four AAA batteries
- Provides power to the circuit with positive and negative terminals
Wiring Details
Arduino Uno R3
3.3Vconnected to the anode of the red LED5Vconnected to the VCC of the HC-05 Bluetooth moduleGNDconnected to the ground of the battery mount, L298N motor driver, and HC-05 Bluetooth moduleVINconnected to the 5V input of the L298N motor driver- Digital pins
13,12,11, and10connected to theIN1,IN2,IN3, andIN4of the L298N motor driver respectively - Digital pin
9connected to the cathode of the red LED - Digital pins
1and0(TX/RX) connected to the RXD and TXD of the HC-05 Bluetooth module
L298N DC Motor Driver
OUT1andOUT2connected to the DC motors (motor A)OUT3andOUT4connected to the DC motors (motor B)12Vconnected to the positive terminal of the battery mountGNDconnected to the ground of the Arduino Uno R3
DC Motors
- Each motor has one pin connected to an
OUTpin on the L298N motor driver and the other pin to anotherOUTpin for the opposite direction
HC-05 Bluetooth Module
VCCconnected to the5Vof the Arduino Uno R3GNDconnected to theGNDof the Arduino Uno R3TXDconnected to theRX(pin0) of the Arduino Uno R3RXDconnected to theTX(pin1) of the Arduino Uno R3
LED: Two Pin (red)
Anodeconnected to the3.3Vof the Arduino Uno R3Cathodeconnected to the digital pin9of the Arduino Uno R3
4 x AAA Battery Mount
+connected to the12Vof the L298N motor driver-connected to theGNDof the Arduino Uno R3
Documented Code
char t;
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(9, OUTPUT); // LED
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 LED on
digitalWrite(9, HIGH);
} else if (t == 'w') { // turn LED off
digitalWrite(9, 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 run on the Arduino Uno R3. It sets up the necessary pins as outputs and initializes serial communication. The loop function reads a character from the serial port and controls the motors and LED based on the received command.