Circuit Documentation
Summary
This circuit is designed to control a set of DC Mini Metal Gear Motors through an L298N 2A Dual Motor Driver Module with PWM Control, interfaced with an Arduino UNO microcontroller. The Arduino UNO also communicates with an HC-05 Bluetooth Module to receive control commands wirelessly. A 12V battery provides power to the system. The circuit is capable of driving the motors in forward and reverse directions, as well as turning on an LED connected to the Arduino.
Component List
Arduino UNO
- Microcontroller board based on the ATmega328P
- It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.
DC Mini Metal Gear Motor
- A compact and powerful DC motor with a metal gearbox for driving the mechanical parts of the system.
L298N 2A Dual Motor Driver Module with PWM Control
- A motor driver module capable of driving two DC motors with PWM speed control.
HC-05 Bluetooth Module
- A wireless communication module that allows the Arduino to communicate with other Bluetooth-enabled devices.
Battery 12V
- A 12V power source for the motor driver module and the motors.
Wiring Details
Arduino UNO
5Vconnected to HC-05 Bluetooth ModuleVCCGNDconnected to:- Battery
12V- - L298N Motor Driver
GND - HC-05 Bluetooth Module
GND
- Battery
Vinconnected to L298N Motor Driver5V- Digital pins
D13,D12,D11,D10connected to L298N Motor DriverIN1,IN2,IN3,IN4respectively - Digital pins
D1,D0connected to HC-05 Bluetooth ModuleRXD,TXDrespectively - Digital pin
D9is unused but configured for an LED in the code
DC Mini Metal Gear Motors
- Two motors connected to L298N Motor Driver
OUT1andOUT2 - Two motors connected to L298N Motor Driver
OUT3andOUT4
L298N 2A Dual Motor Driver Module with PWM Control
OUT1,OUT2,OUT3,OUT4connected to four DC Mini Metal Gear MotorsIN1andIN212Vconnected to Battery12V+GNDconnected to Arduino UNOGND5Vconnected to Arduino UNOVinIN1,IN2,IN3,IN4connected to Arduino UNOD13,D12,D11,D10respectively
HC-05 Bluetooth Module
VCCconnected to Arduino UNO5VGNDconnected to Arduino UNOGNDTXDconnected to Arduino UNOD0RXDconnected to Arduino UNOD1
Battery 12V
+connected to L298N Motor Driver12V-connected to Arduino UNOGND
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 or off)
digitalWrite(9, HIGH);
}
else if (t == 'w') {
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);
}
The code is designed to read characters from the serial input and control the motors and an LED based on the received character. Commands 'F', 'B', 'L', 'R', 'W', 'w', and 'S' correspond to forward, backward, left turn, right turn, LED on, LED off, and stop, respectively.
