Bluetooth-controlled car with an Arduino and a BTS 7960 motor driver for speed control, here’s a step-by-step guide:
Components
- Arduino Uno( microcontroller)
- HC-05 Bluetooth module
- BTS7960 Motor Driver
- DC Motors Johnson 12V motors )
- Power Supply (12V battery for motors, Arduino power)
- Smartphone (Arduino Bluetooth Controller) (App)
Wiring
- HC-05 Bluetooth Module:
- VCC to 5V on Arduino.
- GND to GND on Arduino.
- TX to RX on Arduino (SHOULD I ADD potential voltage divider for 3.3V logic ).
- RX to TX on Arduino.
- BTS7960 Motor Driver:
- RPWM and LPWM to two PWM pins on Arduino (e.g., D5 and D6 for speed control).
- R_EN and L_EN to 5V on Arduino (for enabling motor control).
- VCC to motor power supply (+12V).
- GND to common ground.
- Motor terminals connect to the output terminals of the BTS7960.
- Power Supply: Connect a 12V battery to the BTS7960's power input. I have a common ground between the Arduino and BTS7960 module.
This code reads commands from the Bluetooth module to control the car’s direction and speed:
#include <SoftwareSerial.h>
#define RPWM 5 // Connect to BTS7960 RPWM
#define LPWM 6 // Connect to BTS7960 LPWM
SoftwareSerial Bluetooth(2, 3); // Bluetooth TX to D2, RX to D3
int speedValue = 0;
void setup() {
Serial.begin(9600);
Bluetooth.begin(9600);
pinMode(RPWM, OUTPUT);
pinMode(LPWM, OUTPUT);
Serial.println("Bluetooth Car Ready");
}
void loop() {
if (Bluetooth.available()) {
char command = Bluetooth.read();
switch (command) {
case 'F': // Forward
analogWrite(RPWM, speedValue);
analogWrite(LPWM, 0);
break;
case 'B': // Backward
analogWrite(RPWM, 0);
analogWrite(LPWM, speedValue);
break;
case 'L': // Left turn
analogWrite(RPWM, speedValue / 2);
analogWrite(LPWM, speedValue);
break;
case 'R': // Right turn
analogWrite(RPWM, speedValue);
analogWrite(LPWM, speedValue / 2);
break;
case 'S': // Stop
analogWrite(RPWM, 0);
analogWrite(LPWM, 0);
break;
default: // Adjust speed
if (command >= '0' && command <= '9') {
speedValue = map(command - '0', 0, 9, 0, 255);
Serial.print("Speed set to ");
Serial.println(speedValue);
}
break;
}
}
}
Control
- F - Move Forward
- B - Move Backward
- L - Turn Left
- R - Turn Right
- S - Stop
- 0-9 - (0 for stop, 9 for full speed)`
I am going to make this ! Will it work ?
PLEASE HELP
Anything is appreciated!!
Thanks in advance!!