How to make a radio-controlled tank: spy with remote control and camera. Making a radio-controlled tank using Arduino Nano Do-it-yourself tank battle from arduino

This post will be the first test to see if this is interesting to anyone other than me. I will describe in it general structure, technologies and devices used.

UPD: video added.


To begin with small video to attract attention. The sound comes from the tank's speaker.

Where it all began

A long time ago I had a dream to make a robot on a tracked chassis that could be remotely steered. The main problem was the lack of a directly tracked chassis. In the end I have already decided to buy radio controlled tank for disassembly, but I was lucky, there was a tank among the trash in the store Snow Leopard(Pershing) - USA M26 with burnt electronics, but fully functional mechanical parts. This was exactly what was needed.

In addition to the chassis, two voltage regulators for brushed motors, a camera tripod made of two servos, a webcam with mjpeg hardware support, and an external WiFi card TP-LINK TL-WN7200ND were purchased. A little later, a portable speaker, a Creative SoundBlaster Play USB audio speaker and a simple microphone were added to the list of devices, as well as a couple of USB hubs to connect all this to the control module, which became the Raspberry Pi. The turret from the tank was dismantled, it was very inconvenient to steer it, since all standard mechanics were built on conventional engines without feedback.

Let me make a reservation right away that the photos were taken when the tank was almost ready, and not during the manufacturing process.

Power and Wiring


I stuffed the largest Li-Po battery that would fit into the battery compartment. It turned out to be a two-cell 3300 mAh battery in a hard case, which is usually used in model cars. I was too lazy to solder, so for all the switching I used a standard breadboard with a pitch of 2.54. Later, a second one appeared on the top cover and a cable that connected them. For each of the two engines I had my own voltage regulator, which, as a bonus, provides stabilized power of about 5.6 volts. The Raspberry and WiFi card were powered from one regulator, power from the second went to the servos and a USB hub with peripherals.

Gotta make it move

It had to be started somehow. Raspberry was not chosen by chance. Firstly, it allows you to install a normal full-fledged Linux, and secondly, it has a bunch of GPIO legs, which, among other things, can generate a pulse signal for servos and speed controllers. You can generate such a signal using the ServoBlaster utility. After launch, it creates a file /dev/servoblaster, into which you can write something like 0=150, where 0 is the channel number, and 150 is the pulse length in tens of microseconds, that is, 150 is 1.5 milliseconds (most servos have a range of values 700-2300 ms).
So, we connect the regulators to GPIO pins 7 and 11 and launch the servoblaster with the command:

# servod --min=70 --max=230 --p1pins=7.11
Now, if you write the lines 0=230 and 1=230 to /dev/servoblaster, the tank will rush forward.

Probably enough for the first time. If you like the article, I will slowly write details in next posts. And finally, a few more photos, as well as a freshly shot video. True, the quality was not very good, so I apologize in advance to the aesthetes.


In previous materials, we reviewed videos on making various radio-controlled toys. Let's continue this topic. This time we invite you to familiarize yourself with the manufacturing process of a radio-controlled tank.

We will need:
- finished chassis;
- Arduino Nano;
- 3 servos;
- rotary system;
- toy gun;
- PS2 joystick;
- receiver to joystick;
- battery box;
- rechargeable batteries;
- wires;
- laser.

The finished chassis, the purchase link for which is provided at the end of the material, has two motors, two gearboxes, a switch and a compartment for batteries. According to the author of the idea, buying a ready-made chassis will cost less than making it yourself. If the batteries you plan to use do not fit in the chassis compartment, as in the author's case, you can hide the motor driver there.

The first step is to attach the joystick receiver to the chassis. To do this, remove the cover from it.

We also remove the cover from the gearbox.

We make two holes on the cover that will be used to secure the cover with screws.

Fill the nuts that hold the screws with glue so that they do not unscrew while driving and fall into the gearbox.

Now you need to attach the motor driver. According to the author, when using wires with special connectors, the compartment will not completely close, so you need to bite off the connectors, strip the wires and solder directly to the outputs on the driver.

Before installing the driver, you need to take care of the rotating system for the tank muzzle. To do this, we disassemble the plastic rotary system and install two servos in it. The first will be responsible for horizontal movements, and the second for vertical movements.

Putting the rotary system back together.

We install the system on the tank hull.

You need to make 3 additional holes in the housing. Two of them are needed for the motor wires, and the wide hole is needed for the bus in the motor driver control.

The gun must be connected to a servo drive. To do this, just make a hole in the servo drive and the gun body and connect it with a screw.

The next thing you need to do is connect the trigger of the gun to the servo. To do this, drill holes on the trigger and the attachment on the servo drive. We connect the elements with a piece of wire.

In the upper part of the rotary system, two through holes must be made, which must also pass through the barrel of the gun. These holes will be used to install the muzzle on the rotary system.

Let's move on to programming the Arduino Nano board.

We assemble the remaining components according to the diagram below.

On the top of the chassis we install pieces of rulers that will serve as wings. We install battery compartments on the wings.

We glue the laser to the barrel with hot glue.

Our radio-controlled tank is ready.

Let's build a radio-controlled tank with a first-person view that can be controlled from a distance of up to 2 kilometers! My project is based on a remote control rover, it is easy to build, easy to program and a great hobbyist project!




The bot is very fast and agile, not to mention the fact that it has two powerful engines! It will certainly outrun a human, no matter what surface the race is on!

The bot is still a prototype, even after months of development.

So what is FPV?
FPV, or First Person View, is a First Person View. We usually see FPV while playing games on consoles and computers, such as racing games. FPV is also used by the military for surveillance, defense, or to monitor protected areas. Hobbyists use FPV in quadcopters for aerial filming and just for fun. This all sounds as cool as the cost of building a quadcopter, so we decided to build something smaller that rides on the ground.

How to manage this?
The bot is based on an Arduino board. Since Arduino supports a wide variety of add-ons and modules (RC/WiFi/Bluetooth), you can choose any of the communication types. For this build we will use special components that will allow control over long distances using a 2.4Ghz transmitter and receiver that controls the bot.

There is a demo video in the last step.

Step 1: Tools and Materials






I buy most of my parts at local hobby stores, the rest I find online - just look for deals with best price. I use a lot of Tamiya solutions and my instructions are written with this feature in mind.

I bought spare parts and materials from Gearbest - at that time they were having a sale.

We will need:

  • Arduino UNO R3 clone
  • Pololu Dual VNH5019 Motor Shield (2x30A)
  • Pin dads
  • 4 spacers
  • Screws and nuts
  • Signal transmission module (transmitter) 2.4 Ghz - read more in step 13
  • Receiver 2.4 Ghz for at least two channels
  • 2 Tamiya Plasma Dash / Hyper dash 3 motors
  • Tamiya Twin Motor Gearbox Kit (stock motors included)
  • 2 Tamiya universal boards
  • Tamiya track and wheel set
  • 3 lithium polymer batteries 1500mAh
  • first person camera with support remote control direction and zoom
  • transmitter and data receiver for FPV 5.8Ghz 200mW
  • Bottle of superglue
  • Hot glue

Tool:

  • Multitool
  • Screwdriver set
  • Dremel

Step 2: Assembling the Twin Gearbox


Time to unpack the gearbox. Just follow the instructions and everything will be fine.

Important note: use 58:1 gear ratio!!!

  • lubricate the gears before assembling the box, not after
  • do not forget about metal spacers, otherwise the box will creak
  • use 58:1 gear format, it is faster than 204:1

Step 3: Improving the motors

The gearbox comes with motors, but in my opinion they are very slow. Therefore, I decided to use Hyper dash motors in the project, instead of Plasma Dash, which consume more energy.

However, Plasma Dash motors are the fastest in Tamiya's 4WD motor series. Motors are expensive, but you will get best product for this money. These carbon coated motors spin at 29,000 rpm on 3V and 36,000 rpm on 7V.

The motors are designed to work with 3V power supplies and increasing the voltage, although it increases performance, reduces their service life. With the Pololu 2x30 Motor Driver and two lithium polymer batteries, the Arduino program must be configured to maximum speed 320/400, you will soon find out what this means in the code step.

Step 4: Motor Drivers


I have been interested in robotics for a very long time and I can say. What the best driver engines is Pololu Dual VNH5019. When it comes to power and efficiency, this is best option, but when we talk about price, he is clearly not our friend.

Another option would be to build the L298 driver. 1 L298 is designed for one motor, which is best solution for motors for high strength current. I'll show you how to build your own version of such a driver.

Step 5: Assembling the Tracks




Use your imagination and configure the tracks to your liking.

Step 6: Screw the spacers and attach the FPV



Again, use your imagination and figure out how to position the struts and camera for the first person view. Secure everything with hot glue. Attach the upper deck and drill holes for mounting the FPV antenna and for the installed spacers, then secure everything with screws.

Step 7: Upper Deck


The purpose of creating the upper deck was to increase free space, since the FPV components take up a lot of space on the bottom of the drone, leaving no room for the Arduino and motor driver.

Step 8: Install Arduino and Motor Driver

Simply screw or glue the Arduino into place on the top deck, and then attach the motor driver on top of it.

Step 9: Install the receiver module



It's time to connect the Rx module to the Arduino. Using channels 1 and 2, connect channel 1 to A0 and 2 to A1. Connect the receiver to the 5V and GND pins on the Arduino.

Step 10: Connect the Motors and Batteries



Solder the wires to the motor and connect them to the driver according to the channels. Regarding the battery, you will need to create your own connector using a JST male connector and DINA male connectors. Please look at the photos to better understand what will be required of you.

Step 11: Battery

Take the battery and determine the location where you will install it.

Once you have a location for it, create a male adapter to connect to the battery. The 3S 12V Li-po battery will power the FPV camera, motor and Arduino, so you will need to create a connector for the motor power line and the FPV line.

Step 12: Code for Arduino (C++)

The code is very simple, just download it and everything should work with the VNH motor driver (make sure to download the driver library and put it in the Arduino libraries folder).

The code is similar to Zumobot RC, I just replaced the motor driver library and configured some things.

For L298 driver use standard program Zumobot, just connect everything according to how it is written in the library.

#define PWM_L 10 ///left motor
#define PWM_R 9
#define DIR_L 8 ///left motor
#define DIR_R 7

Just download the code and proceed to the next step.

Files

Step 13: Controller


On the market there is different types controllers for radio controlled toys: for water, earth, air. They also operate on different frequencies: AM, FM, 2.4GHz, but at the end of the day they are all just regular controllers. I don't know exactly the name of the controller, but I know that it is used for aerial drones and has more channels compared to land or water ones.

On at the moment I'm using Turnigy 9XR Transmitter Mode 2 (No Module). As you can see, the name says that it is moduleless, which means that you choose which 2.4GHz communication module to build into it. There are dozens of brands on the market that have their own features of use, control, distance and other various features. Now I'm using FrSky DJT 2.4Ghz Combo Pack for JR w/ Telemetry Module & V8FR-II RX, which is a little expensive, but just look at its specifications and goodies, then the price will not seem so high for all this stuff. Plus the module comes immediately with the receiver!

And remember that even if you have the controller and modules, you will not be able to turn it on until you have batteries that match the controller. Either way, find a controller that suits you and then you'll decide on the right batteries.

Tip: If you're a beginner, seek help from local hobby shops or find ham radio enthusiast groups because this step is no joke and you'll need to shell out a significant amount of money.

Step 14: Check




First turn on the bot, then turn on the transmitter module, after that the receiver module should indicate successful binding by flashing the LED.

Beginner's Guide to FPV

The part installed on the bot is called the FPV transmitter and camera, and what you have in your hands is called the FPV receiver. The receiver connects to any screen - be it LCD, TV, TFT, etc. All you need to do is insert batteries into it or connect it to a power source. Turn it on, then change the channel on the receiver if necessary. After that, you should see on the screen what your bot sees.

FPV signal range

The project used an inexpensive module capable of operating at a distance of up to 1.5 - 2 km, but this applies to using the device on open space if you want to receive a signal greater strength, then buy a higher power transmitter, for example 1000mW. Please note that my transmitter only has 200mW power and was the cheapest I could find.

There's only one last step left - to have fun controlling your new spy tank with camera!

Arduino tank with bluetooth control is a great example of how easily and without special knowledge you can turn an ordinary radio-controlled tank into a cool toy controlled with android devices. Moreover, you don’t even have to edit the code; specialized software will do everything. You may have read my previous article on converting a radio-controlled car model into control. With a tank, everything is almost the same, only it can also rotate the turret and change the elevation angle of the barrel.

To begin with, I present brief overview possibilities of my craft:

Now let's take everything in order.

Arduino tank with bluetooth control - hardware.

The most important thing in hardware is chassis, that is, body. Without the tank itself, nothing will work out for us. When choosing a case, pay attention to free space inside. We will have to place an impressive number of components there. I came across this option, and we will work with it.

Donor for our project.

Initially it was faulty. I wanted to restore it, but being horrified by the build quality of the working board, I decided that a remake would be more reliable. And I’ll delight the children with an old gadget controlled in a new way.

Dimensions: 330x145x105 millimeters excluding the barrel. The hull is equipped with four motors: two for propulsion, one for the turret and one for the barrel. Initially, the tank was able to shoot rubber bullets, but the mechanism was broken, so I simply cut it off the barrel. After this, there was enough space to place the filling.

Download and install the program from the official website and install, you can simply unpack the portable version. Next, open my project file in it and click on the firmware button at the top of the interface (seventh from the left).

FLProg interface

ArduinoIDE will open, but you know how to work in it 😀 .

Arduino tank with bluetooth control - connection diagram

We connect peripheral elements to the board, in our case bluetooth, bridges and LEDs, according to the project.

List of used pins

The list shows the Arduino pin numbers and their purpose. Everything is commented. The motion and turret control contacts with the barrel are connected directly from the bridges, no additional body kit is required. Connecting the analog input for measuring voltage must be done through a resistive divider since the on-board voltage of the arduino is FIVE VOLT!!! This is very important; when the threshold voltage of the microcircuit is exceeded, the controller is sent to another world. So be careful. In my case, two li-ion batteries of the 18650 format were used, a divider with 1 KOhm and 680 Ohm resistors. If your operating voltage is different from mine, then go to any online calculator to calculate the resistive divider and calculate it yourself, based on the fact that its output voltage should be equal to five volts. If you doubt your abilities, then you don’t have to use measuring the voltage on the battery at all; it will work just the same. I stopped driving like that - it's time to charge.

LEDs, if any, must be connected through current-limiting resistors.

Arduino tank with bluetooth control - program for tablet or smartphone.

As in the previous model, we will use a program for Android devices called HmiKaskada. I'm posting free version this program, which can be downloaded from YandexDisk. My project is made in a paid version and it is not compatible with the free version of the program. So further material is devoted to creating a project in the free version.

Control Interface

In the finished project, there is also a battery level indicator on the tablet, and this is the base for the project. So let's get started...

First, let's create a project with one working screen; we won't need any more. Next, we will connect our bluetooth module to the tablet. To do this, go to edit the list of servers and click the plus in the upper right corner. We select our bluetooth from the list and give it a name. Now it's set up and ready to go. Next step This is the installation of a substrate for the work area. To do this, go to the “other - background” menu of the main workspace and load the interface image. You can use mine or create your own image. In fact, it will work without setting the background, it is only for beauty.

Now let's move on to the placement of controls. Go to the “setters” menu and drag the button to the work area. In the button menu, click on the address and enter, for example, 1#0.12. Where 1 is the address of the Arduino board, and 12 is the address of the variable from the project. Variables used in the project can be viewed in the project tree.

List of flag addresses

Setting up the battery charge indicator is exactly the same. We create a storage register in Integer format in the Arduino project and assign its address to the indicator. For example 1#10, customize the indicator to your taste.

When all the controls are created, configured and located in their places, click on start the project. The Android will connect to the tank, and you can enjoy the work done.

Arduino tank with bluetooth control - assembly.

Assembling the craft took about two hours of my time, but the result exceeded all expectations. The tank turned out to be quite nimble and responds to commands instantly. I had to tinker with the gearbox that drives the tank tracks. It fell apart, but fortunately for me the gears were not damaged and a little glue, grease and straight hands brought it back into operation. The standard battery had to be replaced with two li-ion 18650 batteries connected in series in a holder. The final supply voltage was 6 - 8.4 volts, depending on the battery charge level. We also had to replace the motor driving the turret; it was short-circuited.

Replaced the diodes on the headlights of my toy. The low-current yellow ones were absolutely not pleasing and were soldered onto bright white ones from lighters with flashlights :) Now this tracked miracle is comfortable to drive even in complete darkness. Photos before and after:

Wonderful)

The result of the final assembly does not look very neat, I decided not to spend additional time on designing shields and laying wires. And so everything works great.

This is how the “filling” turned out

Arduino tank with bluetooth control - conclusion.

As can be seen from the above material, there is no smell of digging in the code when creating a tank controlled by Bluetooth. We also don’t need any advanced knowledge of electronics. All operations are intuitive and aimed at beginners. Initially, the HMIKaskada program was developed as an alternative to expensive industrial HMI panels, but it was also useful in creating a toy. I hope that I helped you dispel the myth about the difficulty of creating multitasking projects on Arduino.

I will be glad to receive any kind of comments on the article, as well as comments. After all, I am also learning with you...

The robot consists of a chassis from an RC tank and several other components, a list of which is given below. This is my first project on , and I liked the Arduino platform. When creating this robot, I used materials from books and the Internet.

Required materials
1. Chassis from a radio-controlled tank.
2. Arduino Uno.
3. Breadboard and jumpers.
4. Integrated motor driver SN754410NE.
5. Standard servo drive.
6. Ultrasonic rangefinder.
7. 9V battery and connector for it.
8. 4 D batteries and a connector for them.
9. USB cable A-B.
10. Base 6" x 6".

Tools
1. Set of screwdrivers.
2. Hot glue gun.
3. Solder and soldering iron.

Chassis

I took the chassis from a tank I bought for $10. The base can be attached to it anywhere, but I attached it in the middle.

Motor driver SN754410NE

To control the motors I used the SN754410NE driver. I used it because I had it, but you can use another one, like L293.

Now about connecting the driver to the Arduino Uno. Connect all GND pins (4,5,12,13) ​​to GND of the breadboard. Connect driver pins 1 and 16 to pins 9 and 10 of the Arduino. Connect driver pins 2 and 7 to pins 3 and 4 of the Arduino, these are the control pins of the left motor. Connect driver pins 10 and 15 to pins 5 and 6 of the Arduino, these are the control pins of the right motor. Connect contacts 3 and 6 to the left motor, and contacts 14 and 11 to the right. Pins 8 and 16 should be connected to power on the breadboard. Power source: 9V battery.

An ultrasonic rangefinder helps the robot avoid obstacles while moving. It is located on a standard servo, which is located on the front of the robot. When the robot spots an object 10 cm away, the servo starts to spin, looking for a passage, and then the Arduino decides which side is the most pleasant to move around.
Attach a connector to it. Limit the servo so that it cannot turn more than 90 degrees in each direction.

The sensor has three contacts GND, 5V and a signal. Connect GND to GND, 5V to 5V Arduino and connect the signal to pin 7 of Arduino.

Nutrition

Arduino is powered by a 9V battery through the appropriate connector. To power the motors I used 4 D size batteries and the appropriate connector. To power the motors, connect the wires from the holder to the board with SN754410NE.

Assembly

Once all the pieces are ready, it's time to assemble them. First we have to attach the Arduino to the base. Then, using hot glue, we attach the rangefinder with a servo drive to the front of the robot. Then you need to attach the batteries. You can place them anywhere you like, but I placed them next to the Arduino. When everything is ready, you can turn on the robot to make sure the Arduino is working.

Program

So, after assembling the robot, it's time to write a program for it. After spending several days, I wrote it.
The robot will move in a straight line as long as the object is more than 10 cm away. When it notices the object, it begins to rotate the sensor, searching for a path. When scanning is completed, the program selects the optimal side for movement. If the robot is at a dead end, it turns 180 degrees.
The program can be downloaded below. You can modify and supplement it.