This document provides a detailed overview of a Bluetooth-controlled RC car circuit. The circuit uses an Arduino UNO microcontroller, an HC-05 Bluetooth module, an L298N motor driver, and four DC motors. The car can be controlled via a Bluetooth connection from a smartphone or other Bluetooth-enabled device.
HC-05 Bluetooth Module
L298N DC Motor Driver
Arduino UNO
DC Motor (4 units)
9V Battery
7.4V Battery
Power Jack
DC Motor 1
DC Motor 2
DC Motor 3
DC Motor 4
/*
* Arduino-based Bluetooth Controlled RC Car
* This code allows an Arduino UNO to control an RC car using an HC-05 Bluetooth
* module and an L298N motor driver. The car can be controlled via a Bluetooth
* connection from a smartphone or other Bluetooth-enabled device.
*/
#include <SoftwareSerial.h>
// Bluetooth module pins
const int bluetoothTx = 11;
const int bluetoothRx = 10;
// Motor driver pins
const int motorIn1 = 2;
const int motorIn2 = 3;
const int motorIn3 = 4;
const int motorIn4 = 5;
// Create a software serial port for the Bluetooth module
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
void setup() {
// Initialize serial communication
Serial.begin(9600);
bluetooth.begin(9600);
// Initialize motor driver pins as outputs
pinMode(motorIn1, OUTPUT);
pinMode(motorIn2, OUTPUT);
pinMode(motorIn3, OUTPUT);
pinMode(motorIn4, OUTPUT);
}
void loop() {
// Check if data is available from the Bluetooth module
if (bluetooth.available()) {
char command = bluetooth.read();
Serial.println(command);
// Control the motors based on the received command
switch (command) {
case 'F': // Move forward
digitalWrite(motorIn1, HIGH);
digitalWrite(motorIn2, LOW);
digitalWrite(motorIn3, HIGH);
digitalWrite(motorIn4, LOW);
break;
case 'B': // Move backward
digitalWrite(motorIn1, LOW);
digitalWrite(motorIn2, HIGH);
digitalWrite(motorIn3, LOW);
digitalWrite(motorIn4, HIGH);
break;
case 'L': // Turn left
digitalWrite(motorIn1, LOW);
digitalWrite(motorIn2, HIGH);
digitalWrite(motorIn3, HIGH);
digitalWrite(motorIn4, LOW);
break;
case 'R': // Turn right
digitalWrite(motorIn1, HIGH);
digitalWrite(motorIn2, LOW);
digitalWrite(motorIn3, LOW);
digitalWrite(motorIn4, HIGH);
break;
case 'S': // Stop
digitalWrite(motorIn1, LOW);
digitalWrite(motorIn2, LOW);
digitalWrite(motorIn3, LOW);
digitalWrite(motorIn4, LOW);
break;
}
}
}
This code initializes the Bluetooth module and motor driver pins, then continuously checks for commands received via Bluetooth to control the motors accordingly.