Wireless Arduino Controlled Tank (nRF24L01)

32,433

218

85

Introduction: Wireless Arduino Controlled Tank (nRF24L01)

Hi!

Today I'll be showing you how to build an Arduino controlled tank and remote. The 3d printed parts of the tank (with the exception of the controller, track guide and tank cover) were designed by timmiclark and can be found here.

Step 1: Gathering Materials and Tools

You will need the following materials to get started:

  • 1x Arduino UNO(here)
  • 1x Arduino Nano(here)
  • 2x nRF24L01 2.4GHz wireless modules(here)
  • 1x L298N Motor driver(here)
  • 2x Gear motor (the yellow piece of plastic)(here)
  • 1x Joystick(here)
  • 1x 9v battery clip(here)
  • 2x Power switch(here)
  • 2x TR 18650 batteries (and a charger)(here)
  • 1x TR 18650 battery holder for 2 batteries(here)
  • 1x Male to female jumper set(here)

The 3D printed parts consist of (can be found on the bottom of this step):

  • 2x Body
  • 2x TrackMidFrame
  • 52x Track
  • 4x Cog
  • 4x CogBracketInner
  • 4x CogBracketOuter
  • 1x TankCover
  • 1x Controller

You'll also need the following tools:

  • Soldering iron
  • Various drill sizes
  • Super glue
  • Pliers
  • Knife

Step 2: Put Together the Tank

After printing I assembled the tank. All the pieces except for the tracks, cogs and cover were glued together with super glue. The tracks ended up to be too tight around the cogs, it might be an issue with my printer, but I decided to add two extra tracks on each side and design a guide for the tracks. It's not the most convenient solution, but it works.

After I assembled the tank, I drilled holes to fit the wireless module and the power switch. I probably should have drilled the holes before I glued it all together, but it didn't make that much of a difference. I drilled holes and attached motor driver to the bottom of the tank with two M3 bolts.

Optional (if you have the same problem as me):

Print two tank guides from the 'optional' folder and some tracks (I suggest adding one or two on each side).

Step 3: Programming the Tank and Controller

To program the arduino you will need the RF24 library installed. So download the files below and open arduino IDE. Go to Sketch -> Include Library -> Add .ZIP Library and import 'RF24.zip' into there.

Next you'll have to connect the arduino UNO and upload 'tank.ino' to the arduino. we'll conect the wires in the next step.

Now unplug the Arduino UNO and connect the Arduino Nano and upload 'controller.ino' to the Arduino.

Remember to change the 'board' and 'port' settings under tools to the correct board type and port.

Step 4: Wiring the Tank

(the image of the nRF24L01 module is a bottom view)

Wiring the tank:

Connect the following pins.

nRF24L01 pins ---- Arduino pins



• GND 1 ---- GND
• VCC 2 ---- 3.3V
• CE 3 ---- 7
• CSN 4 ---- 8
• SCK 5 ---- 13
• MOSI 6 ---- 11
• MISO 7 ---- 12
• IRQ 8 ---- not connected


L298N ---- Arduino pins



• IN1 ---- 5
• IN2 ---- 6
• IN3 ---- 9
• IN4 ---- 10


As far as the battery pack of the tank is concerned, the ground wire goes to the GND pin of the arduino and the GND pin of the motor driver. the power wire goes to Vin pin of the arduino and to the +12V pin of the motor driver via the power switch. Oh, and the +5V pin of the motor driver is attached to the 5V pin of the arduino.

Step 5: ​Wiring the Controller

Wiring the Controller

nRF24L01 pins ---- Arduino pins



• GND 1 ---- GND
• VCC 2 ---- 3.3V
• CE 3 ---- 7
• CSN 4 ---- 8
• SCK 5 ---- 13
• MOSI 6 ---- 11
• MISO 7 ---- 12
• IRQ 8 ---- not connected


Joystick ---- Arduino pins



• GND ---- GND
• +5V ---- 5V
• VRx ---- A0
• VRy ---- A1


It's a bit of a puzzle, fitting all the components into the controller, but with some patience I'm sure you'll manage

Step 6: Test the Tank!

Now, if all goes well, you should be able to control the tank with the controller. if the tracks move in the wrong direction you can either change the code(which is a pain) or you can flip the wires running to the motor driver.

If the tank doesn't work at all you should check the connections of the nRF24L01. you can also connect both Arduino's to the computer, open two different arduino instances, open serial monitor on both and check if the signals are sent and/or received. Please note that if the controller prints the reading of the X and Y values it doesn't mean those signals reach the module.

~Ryan

Robotics Contest 2016

Participated in the
Robotics Contest 2016

Make it Move Contest 2016

Participated in the
Make it Move Contest 2016

First Time Author Contest 2016

Participated in the
First Time Author Contest 2016

6 People Made This Project!

Recommendations

  • Puzzles Speed Challenge

    Puzzles Speed Challenge
  • "Can't Touch This" Family Contest

    "Can't Touch This" Family Contest
  • CNC Contest 2020

    CNC Contest 2020

85 Discussions

0
chickenhawk 1
chickenhawk 1

Question 7 months ago

Ok if Ryan is no longer watching this, does any one know why my grandson is getting this " Error compiling for mega or mega 2560" ? for both the control side and the tank size

0
RyanKolk
RyanKolk

Answer 7 months ago

Hi,
To help you I'm going to need the full error.
Would you mind expanding the bottom window of the IDE, copy the full error message and sending it over to me?

0
chickenhawk 1
chickenhawk 1

Reply 7 months ago

We got it working, but he now is trying to add your " servo knob sketch " to the tank/controller sketches but is not having much luck. Can you give him a hand?
Thanks Peter

0
chickenhawk 1
chickenhawk 1

7 months ago

We got to compile, Ryan if you are watching this we do have a couple of questions

0
chickenhawk 1
chickenhawk 1

Question 7 months ago

Ryan did see the error code?

0
chickenhawk 1
chickenhawk 1

7 months ago

exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

0
chickenhawk 1
chickenhawk 1

7 months ago

I now this is from 2016 but Ryan are you still following this?

0
dineshw6
dineshw6

Question 9 months ago on Step 6

hi i am done this as you say. i used 2 arduino nano boards for this. but t didnt work. nothing happen

0
sasamjimvincent
sasamjimvincent

Question 1 year ago

Hi I'm struggling a little bit in programing the arduino ... Can you pls. give me the full code

0
chinmaypm
chinmaypm

Question 1 year ago

CAN I USE ARDUINO UNO INSTEAD OF ARDUINO NANO FOR CONTROLLER?

0
JESSETHEANIMAL
JESSETHEANIMAL

Answer 1 year ago

sure thing, the pins are the same just change the board, here's how
Tools - Board - arduino/genuino uno

1
coogan57
coogan57

1 year ago

I don't know if your still out there but if you are I need some advice. When I turn on tank power one motor runs, but nothing happens when I move the joystick .The controller code seems to be missing something.

0
MrXtm200M
MrXtm200M

Question 2 years ago

How to add a turret ?

1
anv3D
anv3D

Question 2 years ago

Hi, would it be possible to add a turret?

0
AndreasV6
AndreasV6

2 years ago

Thanks a lot for this instructable! I've been struggling with this exact thing for days (joystick & nRF24L01 module for controlling a robot). I followed your wiring scheme (plus a 100 uF cap for each 2.4 GHz module on the power rails), uploaded your sketches and it worked like a charm. Thanks a lot!

0
tulpek
tulpek

3 years ago

Hi
Sorry to bother you with another stupid question but I have small issue that hopefully you'll be able to help me with, the issue is that after connecting everything up like in your instructable and loading the sketches to Uno and Nano, after powering up my motors keep running forward with the joistick in the center, when I pull the joistick back it changes to reverse same for left or right so that's all good, but forward or center position of the joistick keeps the motors running forward so I can't stop the tank. Thank You

0
RyanKolk
RyanKolk

Reply 3 years ago

Hi,

If you plug the controller into the the computer and open a serial monitor at baud rate 115200, what are the values of x and y when the joystick is not touched?

0
KENESH
KENESH

Reply 3 years ago

Hi,

I've got the same problem , value of X = 1023, Y = 490 ~ 493.

Thank You

0
RyanKolk
RyanKolk

Reply 3 years ago

For the Y-axis all you have to do is change all the

Y > 500 and Y < 500 to Y > 480 and Y < 480 and

Y > 524 and Y < 524 to Y > 502 and Y < 502 and also 'map(Y,524,1024,0,255);' to 'map(Y,504,1024,0,255);' and

'map(Y,500,0,0,255);' to 'map(Y,480,0,0,255);' in the tank code

but it seems that the potentiometer of the x-axis is either broken or not correctly connected.

0
chrispbacon72
chrispbacon72

Reply 2 years ago

How do you do that? I am new to this