Introduction: Arduino Rc Tank
This is a phone controlled(via Bluetooth) Arduino Rc tank. Runs without much difficulty on most of the terrains.
Step 1: Get the Parts:-
Hardware required:-
Arduino Uno R3
Arduino motor driver shield
Geared motors x4
Hc-05 Bluetooth module
Battery tray(8x1.5v)
Jumper wires
Chassis and wheels with tracks
Arduino enclosure(optional for safety)
wires
Batteries
Smartphone
Power jacks(optional)
Tools required:-(makes everything easier because you won't be going to do every single thing by your BareHands)
Soldering iron
Solder wire
Flathead screwdriver
others as per your convenience
Arduino Uno R3
Arduino motor driver shield
Geared motors x4
Hc-05 Bluetooth module
Battery tray(8x1.5v)
Jumper wires
Chassis and wheels with tracks
Arduino enclosure(optional for safety)
wires
Batteries
Smartphone
Power jacks(optional)
Tools required:-(makes everything easier because you won't be going to do every single thing by your BareHands)
Soldering iron
Solder wire
Flathead screwdriver
others as per your convenience
Step 2: Prepare Everything:-
Build the chassis completely.
Prepare your shield(if you have to assemble it)
Prepare your shield(if you have to assemble it)
Step 3: Building It:-
Insert the motor shield on the Arduino.
Insert jumper wires into the Hc-05.
Connect the Gnd pin into the Gnd port on the shield and the Vcc port on the 5v(Vcc) on the shield. The Txd pin on arduino's 0pin and the Rxd on 1 pin(you may have to flip the position of those two if it doesn't work because my works in this way. every module has different configuration). I soldered the wires into the pins directly because i didn't have ports and to make it more secure.
Add the power cable to the EXT_PWR on the shield.
Join each motor to its respected ports 1,2,3 and 4 with correct polarity for all
I used power jacks to make connections easier.
Insert jumper wires into the Hc-05.
Connect the Gnd pin into the Gnd port on the shield and the Vcc port on the 5v(Vcc) on the shield. The Txd pin on arduino's 0pin and the Rxd on 1 pin(you may have to flip the position of those two if it doesn't work because my works in this way. every module has different configuration). I soldered the wires into the pins directly because i didn't have ports and to make it more secure.
Add the power cable to the EXT_PWR on the shield.
Join each motor to its respected ports 1,2,3 and 4 with correct polarity for all
I used power jacks to make connections easier.
Step 4: The Code:-
Connect your Arduino to your preferred device and upload the code.
pls modify the code as per your convenience and your parts because you will not find the exact parts.
Code:-
#include
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);
char command;
void setup()
{
Serial.begin(9600); // Set the baud rate to your Bluetooth module
}
void loop(){
if(Serial.available(),>0){
command=Serial.read();
Stop(); // initialize with motors stopped
//Change pin mode only if new command is different from previous.
//Serial.printIn(command);
switch(command) {
case 'F':
forward();
break;
case 'B':
back();
break;
case 'L':
left();
break;
case 'R':
right();
break;
case 'G':
forwardleft();
break;
case 'I':
forward right();
break;
case 'H':
:backleft();
break;
case 'J':
:backright();
break;
}
}
}
void forward()
{
motor1.setSpeed(255);
motor1.run(FORWARD);
motor2.setSpeed(255);
motor2.run(FORWARD);
motor3.setSpeed(255);
motor3.run(FORWARD);
motor4.setSpeed(255);
motor4.run(FORWARD);
}
void back()
{
motor1.setSpeed(255);
motor1.run(BACKWARD);
motor2.setSpeed(255);
motor2.run(BACKWARD);
motor3.setSpeed(255);
motor3.run(BACKWARD);
motor4.setSpeed(255);
motor4.run(BACKWARD);
}
void left()
{
motor1.setSpeed(0);
motor1.run(RELEASE);
motor2.setSpeed(0);
motor2.run(RELEASE);
motor3.setSpeed(255);
motor3.run(FORWARD);
motor4.setSpeed(255);
motor4.run(FORWARD);
}
void right()
{
motor1.setSpeed(255);
motor1.run(FORWARD);
motor2.setSpeed(255);
motor2.run(FORWARD);
motor3.setSpeed(0);
motor3.run(RELEASE);
motor4.setSpeed(0);
motor4.run(RELEASE);
}
void forwardleft()
{
motor1.setSpeed(240);
motor1.run(FORWARD);
motor2.setSpeed(240);
motor2.run(FORWARD);
motor3.setSpeed(255);
motor3.run(FORWARD);
motor4.setSpeed(255);
motor4.run(FORWARD);
}
void forwardright()
{
motor1.setSpeed(255);
motor1.run(FORWARD);
motor2.setSpeed(255);
motor2.run(FORWARD);
motor3.setSpeed(240);
motor3.run(FORWARD);
motor4.setSpeed(240);
motor4.run(FORWARD);
}
void backleft()
{
motor1.setSpeed(240);
motor1.run(BACKWARD);
motor2.setSpeed(240);
motor2.run(BACKWARD);
motor3.setSpeed(255);
motor3.run(BACKWARD);
motor4.setSpeed(255);
motor4.run(BACKWARD);
}
void backright()
{
motor1.setSpeed(255);
motor1.run(BACKWARD);
motor2.setSpeed(255);
motor2.run(BACKWARD);
motor3.setSpeed(240);
motor3.run(BACKWARD);
motor4.setSpeed(240);
motor4.run(BACKWARD);
}
void Stop()
{
motor1.setSpeed(0);
motor1.run(RELEASE);
motor2.setSpeed(0);
motor2.run(RELEASE);
motor3.setSpeed(0);
motor3.run(RELEASE);
motor4.setSpeed(0);
motor4.run(RELEASE);
}
pls change the motor values as per your convenience and motors
pls modify the code as per your convenience and your parts because you will not find the exact parts.
Code:-
#include
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);
char command;
void setup()
{
Serial.begin(9600); // Set the baud rate to your Bluetooth module
}
void loop(){
if(Serial.available(),>0){
command=Serial.read();
Stop(); // initialize with motors stopped
//Change pin mode only if new command is different from previous.
//Serial.printIn(command);
switch(command) {
case 'F':
forward();
break;
case 'B':
back();
break;
case 'L':
left();
break;
case 'R':
right();
break;
case 'G':
forwardleft();
break;
case 'I':
forward right();
break;
case 'H':
:backleft();
break;
case 'J':
:backright();
break;
}
}
}
void forward()
{
motor1.setSpeed(255);
motor1.run(FORWARD);
motor2.setSpeed(255);
motor2.run(FORWARD);
motor3.setSpeed(255);
motor3.run(FORWARD);
motor4.setSpeed(255);
motor4.run(FORWARD);
}
void back()
{
motor1.setSpeed(255);
motor1.run(BACKWARD);
motor2.setSpeed(255);
motor2.run(BACKWARD);
motor3.setSpeed(255);
motor3.run(BACKWARD);
motor4.setSpeed(255);
motor4.run(BACKWARD);
}
void left()
{
motor1.setSpeed(0);
motor1.run(RELEASE);
motor2.setSpeed(0);
motor2.run(RELEASE);
motor3.setSpeed(255);
motor3.run(FORWARD);
motor4.setSpeed(255);
motor4.run(FORWARD);
}
void right()
{
motor1.setSpeed(255);
motor1.run(FORWARD);
motor2.setSpeed(255);
motor2.run(FORWARD);
motor3.setSpeed(0);
motor3.run(RELEASE);
motor4.setSpeed(0);
motor4.run(RELEASE);
}
void forwardleft()
{
motor1.setSpeed(240);
motor1.run(FORWARD);
motor2.setSpeed(240);
motor2.run(FORWARD);
motor3.setSpeed(255);
motor3.run(FORWARD);
motor4.setSpeed(255);
motor4.run(FORWARD);
}
void forwardright()
{
motor1.setSpeed(255);
motor1.run(FORWARD);
motor2.setSpeed(255);
motor2.run(FORWARD);
motor3.setSpeed(240);
motor3.run(FORWARD);
motor4.setSpeed(240);
motor4.run(FORWARD);
}
void backleft()
{
motor1.setSpeed(240);
motor1.run(BACKWARD);
motor2.setSpeed(240);
motor2.run(BACKWARD);
motor3.setSpeed(255);
motor3.run(BACKWARD);
motor4.setSpeed(255);
motor4.run(BACKWARD);
}
void backright()
{
motor1.setSpeed(255);
motor1.run(BACKWARD);
motor2.setSpeed(255);
motor2.run(BACKWARD);
motor3.setSpeed(240);
motor3.run(BACKWARD);
motor4.setSpeed(240);
motor4.run(BACKWARD);
}
void Stop()
{
motor1.setSpeed(0);
motor1.run(RELEASE);
motor2.setSpeed(0);
motor2.run(RELEASE);
motor3.setSpeed(0);
motor3.run(RELEASE);
motor4.setSpeed(0);
motor4.run(RELEASE);
}
pls change the motor values as per your convenience and motors
Step 5: App for Your Phone:-
Download Bluetooth rc car
other will also work but you will have to set the commands accordingly
other will also work but you will have to set the commands accordingly
Step 6: Have Fun
I apologize for any mistakes as this is my first instructable
If you find any difficulty then feel free to ask. i will try to make its upgraded version soon.
Pls vote for my project as i am entering it in the robotics contest.
Thank you
If you find any difficulty then feel free to ask. i will try to make its upgraded version soon.
Pls vote for my project as i am entering it in the robotics contest.
Thank you