Components Required
- Arduino UNO
- HW-130 Motor Driver Shield (L293D based)
- 4 × DC Gear Motors
- Bluetooth Module (HC-05 or HC-06)
- 2 × Rubber Tank Tracks
- Li-ion Battery Pack
- Jumper Wires
- Robot Tank Chassis
Motor Connections
Your 4 motors will act like a tank drive system:
- Left Side Motors → M1 and M2
- Right Side Motors → M3 and M4
| Motor Driver Port | Motor |
|---|---|
| M1 | Left Front Motor |
| M2 | Left Rear Motor |
| M3 | Right Front Motor |
| M4 | Right Rear Motor |
Simply connect the motors to the screw terminals on the HW-130 shield.
Bluetooth Module Connection
Since the shield uses most digital pins, we will use A0 and A1 as SoftwareSerial pins.
| Bluetooth Pin | Arduino Pin |
|---|---|
| VCC | 5V |
| GND | GND |
| TX | A0 |
| RX | A1 |
Power Connection
Motor power should NOT come from Arduino USB.
Recommended:
- Battery + → Motor Shield EXT_PWR
- Battery – → Motor Shield GND
Voltage range:
- 7V – 12V recommended
Control Commands
The robot will respond to these commands from a Bluetooth App:
| Command | Action |
|---|---|
| F | Move Forward |
| B | Move Backward |
| L | Turn Left |
| R | Turn Right |
| S | Stop |
You can send these commands from apps like:
- Arduino Bluetooth Controller
- Serial Bluetooth Terminal
- Bluetooth RC Controller
Arduino Code
Install Library first:
AFMotor Library
Open Arduino IDE then follow below steps:
Click Tools → Manage Libraries → Search AFMotor
#include <AFMotor.h>
#include <SoftwareSerial.h>
// Bluetooth RX, TX
SoftwareSerial BT(A0, A1);
// Motors
AF_DCMotor motor1(1); // Left Front
AF_DCMotor motor2(2); // Left Rear
AF_DCMotor motor3(3); // Right Front
AF_DCMotor motor4(4); // Right Rear
char command;
void setup()
{
Serial.begin(9600);
BT.begin(9600);
motor1.setSpeed(225);
motor2.setSpeed(225);
motor3.setSpeed(225);
motor4.setSpeed(225);
}
void loop()
{
if (BT.available())
{
command = BT.read();
Serial.println(command);
if (command == 'F')
{
forward();
}
else if (command == 'B')
{
backward();
}
else if (command == 'L')
{
left();
}
else if (command == 'R')
{
right();
}
else if (command == 'S')
{
stopRobot();
}
}
}
void forward()
{
motor1.run(FORWARD);
motor2.run(FORWARD);
motor3.run(FORWARD);
motor4.run(FORWARD);
}
void backward()
{
motor1.run(BACKWARD);
motor2.run(BACKWARD);
motor3.run(BACKWARD);
motor4.run(BACKWARD);
}
void left()
{
motor1.run(BACKWARD);
motor2.run(BACKWARD);
motor3.run(FORWARD);
motor4.run(FORWARD);
}
void right()
{
motor1.run(FORWARD);
motor2.run(FORWARD);
motor3.run(BACKWARD);
motor4.run(BACKWARD);
}
void stopRobot()
{
motor1.run(RELEASE);
motor2.run(RELEASE);
motor3.run(RELEASE);
motor4.run(RELEASE);
}
Please Note: Pair HC-05 with phone Bluetooth first. Then Connect HC-05 with Bluetooth RC Controller APP.