

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.
5V connected to HC-06 VCC.GND connected to 18650 Li-ion Battery -, PWM motor speed controller Power-, and L298N motor driver GND.Vin connected to L298N motor driver 5V.D13 connected to L298N motor driver IN1.D12 connected to L298N motor driver IN2.D11 connected to L298N motor driver IN3.D10 connected to L298N motor driver IN4.D6 connected to L298N motor driver ENA.D5 connected to L298N motor driver ENB.D1 connected to HC-06 RXD.D0 connected to HC-06 TXD.PIN1 connected to L298N motor driver OUT1.PIN2 connected to L298N motor driver OUT2.PIN1 connected to L298N motor driver OUT4.PIN2 connected to L298N motor driver OUT3.Motor+ connected to both Gearmotor DC / Motorreductor Pin1.Motor- connected to both Gearmotor DC / Motorreductor Pin2.Power+ connected to Rocker Switch 1 and 18650 Li-ion Battery +.12V connected to Rocker Switch 2.GND connected to Arduino UNO GND.1 connected to 18650 Li-ion Battery + and PWM motor speed controller Power+.2 connected to L298N motor driver 12V.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'.