Hey guys, we are back with another cool DIY robot. This is Quad Rail – A DIY Remote Controlled Tank. This is a 4 motors-driven Arduino-tracked robot. I will be giving you complete details including the schematics, PCB files, and complete codes so that you can build one like this, or modify this and make your own version of it. 

Arduino RC Tank In a Nutshell

We will provide you with the design, code, circuit diagrams and links to buy your own robot kit, chassis and the sensor modules used in this project.

DIY Remote Controlled Tank Video Tutorial

Dont want to read the entire stuff? Dont worry, we have a video guide for you. Check out the below video.

We are super excited to teach you everything you need to know about Arduino, robotics, and other fun DIY hobby projects. If you are a true fan of Arduino and you are really interested in building amazing DIY projects, then this channel is for you. So make sure you subscribe to our channel by hitting the subscribe button here. Now, let’s get started with the project.

Step 1 – Tracked Robot Chassis

I got this Tracked robot chassis from Banggood. Unlike our previous Robots, this once has tracked wheels instead of the tires.

Tracked Robot Chassis – Tank Tread for Robotics

This enables the RC Tank to travel over different kinds of terrains. It also has a spring suspension mechanism, for every wheel, so that the front plate will automatically adjust to obstacles and move over it.

Step 2 – The Remote Controller for DIY Remote Controlled Tank

Remote Controller Working

We will be controlling this Arduino tracked robot using an HC12 wireless module-based remote controller. This wireless module mainly contains an accelerometer, a joystick, and four switches. the microcontroller collects input from all the sensors and it will be concatenated into a long string of variables separated by a comma.

This line is sent to the HC12 wireless module which will transmit these signals over the air to all his HC12 wireless modules within its vicinity.

How to make Remote Controller?

It is very easy to make a remote controller using an HC12 wireless module. All you need is an Arduino, some sensors like Joystick, accelerometer or switches, and of course an HC12 wireless module. All you have to do is collect all the data from the sensors, condition them and transmit them via the HC12 wireless module. You can either make your own version of it or follow our long-range remote controller tutorial and make the same one, I am using. Check out the below video.

Step 3 – Drawing the Circuit for DIY Remote Controlled Tank

This is the circuit that we will be using on the Arduino RC Tank side. I used Altium designer to draw the circuit and design the PCB. It is a powerful tool that can be used to design and create your own PCBs for your project as well as complex and multi-layer PCBs for industrial use. I will provide the link to the free version in the description. Make sure you check it out!

Arduino RC Tank Circuit

The circuit contains a terminal block called Vin where we will be connecting input power. You can connect a 9-volt battery, 12-volt lithium polymer battery or if you are planning on building a wired robot you can use a 12-volt dc adaptor. This input power is then connected to a 7805 voltage regulator. This voltage regulator converts unregulated voltage between 7 to 32 volt to a steady 5-volt dc power supply. This 5 volt is then fed to HC12 wireless module, L293D motor driver ic, and to Arduino.

Or you can connect this voltage input directly to the Vin pin of Arduino. Since we have four motors in the DIY Remote Controlled Tank will be connecting two on either side. On the left, you will see left motor 1 and left motor 2 and on the right side, you see right motor 1 and right motor 2. 

Input for the left motors, that is input 1, input 2, and enable 1 will be connected to D4, D5, and D2 of the microcontroller. Whereas input for right motors, that is input 3 input 4 and enable 2 will be connected to D6, D7, and D3 of the microcontroller. 

Pin numbers 8 and 9 of Arduino will be connected to the pin and Rx pin of the HC12 wireless module. These pins work as a software serial interface using which we will be fetching the data from the HC12 wireless module.

Arduino Tracked Robot Circuit Summary

Let me give you a short summary. This circuit will collect all the data from the HC12 wireless module of the remote controller, using the HC12 module connected to the Arduino of your DIY Remote Controlled Tank.  This includes the sensor values in a single line separated by a comma every 10 ms. 

This data is then passed onto Arduino. The Arduino then processes the signals, separates them into different variables, and sends signals to the L293D motor driver ic which will drive the motors. 

Step 4 – Getting PCB Done

Once the circuit was finished, I designed a compact PCB using Altium, where I can fix all the components neatly. Here you can see, routing is on both sides of the board, but components are placed on the top side. And that’s done. Now all you have to do is export the Gerber.

Odering PCB from PCBWay

I ordered PCB from PCBWay. Pcbway is a PCB manufacturer specializing in PCB prototyping, low-volume production, and neat and tidy PCB assembly. To order your PCB from the PCBWay, go to the PCBWay website and fill in the basic board details in the instant order form.

Ordering PCBs from PCBWay

From there you will be directed to a form where you can provide more elaborate board details. Update your board information in the PCB specification screen. In the next screen, you should be able to upload your Gerber file and submit it for review. Once the review is completed, all that is left is to add to the cart, make payment, and wait for your PCBs to arrive.

Step 5 – Assembling the PCB

Once you get all the components and the PCB, it’s time for you to solder them together. Solder all the components onto the board and make sure to check the polarity of the components. After soldering the PCB looks like this.

Step 6 – Coding

Now, let’s get down to the software part. Here, I will be programming the board using our favorite Arduino ide.

This is the code for your Arduino Tracked Robot.

Code

#include <SoftwareSerial.h>
#include <Wire.h>

SoftwareSerial HC12(8, 9);

int lr, x, y;
int bf, motor1_speed, motor2_speed;
int mode;
String input;
int boundLow;
int boundHigh;
const char delimiter = ',';

void setup() {

  Serial.begin(9600);
  HC12.begin(9600);

  pinMode (2, OUTPUT);
  pinMode (3, OUTPUT);
  pinMode (4, OUTPUT);
  pinMode (5, OUTPUT);
  pinMode (6, OUTPUT);
  pinMode (7, OUTPUT);
}

void loop() {
  if (HC12.available())
  {
    input = HC12.readStringUntil('\n');
    if (input.length() > 0)
    {
      Serial.println(input);

      boundLow = input.indexOf(delimiter);
      x = input.substring(0, boundLow).toInt();

      boundHigh = input.indexOf(delimiter, boundLow + 1);
      y = input.substring(boundLow + 1, boundHigh).toInt();

      boundLow = input.indexOf(delimiter, boundHigh + 1);
      bf = input.substring(boundHigh + 1, boundLow).toInt();

      boundHigh = input.indexOf(delimiter, boundLow + 1);
      lr = input.substring(boundLow + 1, boundHigh).toInt();

      mode = input.substring(boundHigh + 1).toInt();

      delay(10);
    }
    drive_robot(); //Comment this line and uncomment the next line for high speed
  }

}


void drive_robot()
{

  if ((bf <= 100) && (lr > 100) && (lr < 700))
  {
    left();
  }

  else if ((bf >= 700) && (lr > 100) && (lr < 700))
  {
    right();
  }

  else if ((lr <= 100) && (bf > 100) && (bf < 700))
  {
    backward();
  }

  else if ((lr >= 700) && (bf > 100) && (bf < 700))
  {
    forward();
  }

  else if ((lr <= 100) && (bf >= 700))
  {
    forward();
  }

  else if ((lr >= 700) && (bf >= 700))
  {
    backward();
  }
  else

  {
    stopp();
  }
}


void forward()
{
  analogWrite(2, 254);
  analogWrite(3, 254);

  digitalWrite(5, LOW);
  digitalWrite(4, HIGH);
  digitalWrite(7, LOW);
  digitalWrite(6, HIGH);
  Serial.println("Forward");
}

void backward()
{
  analogWrite(2, 254);
  analogWrite(3, 254);

  digitalWrite(5, HIGH);
  digitalWrite(4, LOW);
  digitalWrite(7, HIGH);
  digitalWrite(6, LOW);
  Serial.println("Backward");
}

void right()
{
  analogWrite(2, 200);
  analogWrite(3, 199);

  digitalWrite(5, LOW);
  digitalWrite(4, HIGH);
  digitalWrite(7, HIGH);
  digitalWrite(6, LOW);
  Serial.println("Right");
}
void left()
{
  analogWrite(2, 199);
  analogWrite(3, 200);

  digitalWrite(5, HIGH);
  digitalWrite(4, LOW);
  digitalWrite(7, LOW);
  digitalWrite(6, HIGH);
  Serial.println("Left");
}

void stopp()
{
  analogWrite(2, 0);
  analogWrite(3, 0);

  digitalWrite(5, LOW);
  digitalWrite(4, LOW);
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);
  Serial.println("Stop");
}

DIY Remote Controlled Tank Code Explaination

The first thing to do is, include all the libraries that are required for our program.  After that, we will define a software serial interface at pins 8 and 9.  This is where we will be conducting the Tx and Rx pins of the HC12 wireless module.  After that, we will declare some variables that will be used for separating and storing the variables.

In the setup function, we will initiate the serial and software serial communication.  After that, we will declare all the pins as output as will be connecting it to L293D motor driver ic for controlling the dc motors.

In the loop function, we will check for any incoming packets in the software serial interface at Pin 8 and 9.  If there is any data coming through that software serial interface,  it will be stored in string variable input.  After that, this will be broken down into separate sensor values and will be stored in these variables.  Once we have done that we will call the drive_robot function.

In the drive-robot function, we will provide conditions to drive the RC Tank the way we want depending on the value of the variables.  There are five functions forward, backward, left, right, and stop,  which will turn on and off the pins that are connected to the L293D motor driver ic and control the motors. 

Step 7 – Test Driving DIY Remote Controlled Tank

That’s it guys now all you have to do is  select the right port and board and upload the code.

DIY Remote Controlled Tank using Arduino

Now you can power on the entire Arduino Tracked Robot and try moving the joystick of the remote controller.  If everything is working right you should be able to control our robot using the remote controller.

You will find a lot of awesome diy projects in our channel so make sure you check it out. If you have any questions regarding this project for any other projects do ask it in the comments. 

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *