loading

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.

If you have any problems or suggestions please comment and I will try to response in a timely fashion.

~Ryan

<p>I'm having trouble making a code that uses two joysticks that control there own separate motor. Can you help please? :)</p>
Hi<br>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
<p>Hi,</p><p>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?</p>
Hi the X reads 514 and Y reads 483-484
Hey, <br>If you do the same thing as described in the other comment I posted it should work, but instead of 480 and 502 you might want to do 470 and 492
<p>Hi,</p><p>I've got the same problem , value of X = 1023, Y = 490 ~ 493.</p><p>Thank You</p>
<p>For the Y-axis all you have to do is change all the </p><p>Y &gt; 500 and Y &lt; 500 to Y &gt; 480 and Y &lt; 480 and </p><p>Y &gt; 524 and Y &lt; 524 to Y &gt; 502 and Y &lt; 502 and also 'map(Y,524,1024,0,255);' to 'map(Y,504,1024,0,255);' and </p><p>'map(Y,500,0,0,255);' to 'map(Y,480,0,0,255);' in the tank code</p><p>but it seems that the potentiometer of the x-axis is either broken or not correctly connected.</p>
These are the connection diagrams .i just need help with the codes
ookay, ill have a look and get back to you asap
Thank you for helping me out.I prefer your pin connections with only changes in the transmitter as this pin connection uses a L293d motor driver
<p>i need to use the codes for my college project. But i need to use two joysticks with their y axis in control .First joystick with its y axis for forward n backward control and the other joystick with its y axis for right n left direction control. I tried coding but i am really bad at it.Can you please provide me the codes??????</p><p>exactly like this project <iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/H-0HpOxJT_o" width="500"></iframe></p><p>can you please help me out?</p>
Hi!<br>From what I read I think you can achieve what you need by hooking up the x-axis running to the arduino to the y-axis on the second joystick.<br>Or do you want each joystick controlling one motor?
Yeah . I want each joystick to control one motor with its y axis only.So the hooking up of x axis of the joystick to the y axis of other joystick wont help.I need codes that would control one motor with one joystick.<br>
instead of 24l01 transceiver how to use rf 433mhz?
<p>No, dont use radio as the distance sucks</p>
Looks good!<br>Personally I have never worked with the rf 433 mhz, but I would guess that if you get a simple send and receive code running, you could send the analog inputs from a joystick. Try searchin for something similar on the internet. sorry I cant help much more that that
<p>if you put both power sources like you did, how do you connect them to a switch without giving the arduino and the motor driver the same amount of power?</p>
<p>Great project, i used this setup on a different tank chassis,which didn't turn very well but besides that the only problem i had was when you turn the remote on first, then the tank, the tank moves on it's own but only forward. However if you turn the tank on then the remote it seems to work fine. </p>
<p>ioctl(&quot;TIOCMGET&quot;): Inappropriate ioctl for device</p><p>do you know how i can fix this?</p>
<p>I'm sorry for all the stupid questions below. i was eager to finish this and skipped some steps. and if you could explain, how does one add a single button for a servo?</p>
Tx and Rx on arduino uno does not light al all.. please help bro...
<p>I had the same problem with one of my arduino's, for some reason it doesn't work on some arduino's. could you try changing an arduino? if the problem persists i'll be happy to try and help.</p>
<p>Great Project , easy and clear steps , thanks for sharing<br>Now I want to add a 2dof robotic claw clamp to the tank , and I've been struggling to do so with no success in sketching so far<br>If you could help me with a sketch for 2 servos that will work with your given setup then it will be great<br>Thanks !!<br></p>
<p>Hi! All you have to do is add the new lines to 'struct package' in controller and tank:</p><blockquote>struct package<br>{<br>int X=1;<br>int Y=1;<br><b>int servo1=1;<br></b><b>int servo2=1;<br></b>};</blockquote><p>then you can create the controller code however you want, and on the receiving end all you have to do is map 'data.servo1' or 'data.servo2' to 0 to 180 and then write it to the servo.<br></p><p>If that doesn't help, i made a quick sketch based on the servo knob sketch:</p><p>Transmitter:</p><blockquote>#include &lt;SPI.h&gt;<br>#include &quot;RF24.h&quot;<br>RF24 myRadio (7, 8);<br>byte addresses[][6] = {&quot;0&quot;};<br>struct package<br>{<br> int servo1=1;<br>};<br>typedef struct package Package;<br>Package data;<br>void setup()<br>{<br> Serial.begin(115200);<br> delay(100);<br> myRadio.begin();<br> myRadio.setChannel(115);<br> myRadio.setPALevel(RF24_PA_MIN);<br> myRadio.setDataRate( RF24_250KBPS ) ;<br> myRadio.openWritingPipe( addresses[0]);<br> delay(100);<br>}<br>void loop()<br>{<br> myRadio.write(&amp;data, sizeof(data));<br> Serial.print(data.servo1);<br> data.servo1 = analogRead(A0);<br> delay(100);<br>}</blockquote><p>Receiver:</p><blockquote>#include &lt;SPI.h&gt;<br>#include &lt;Servo.h&gt;<br>#include &quot;RF24.h&quot;<br>RF24 myRadio (7, 8);<br>struct package<br>{<br> int servo1=1;<br>};<br>byte addresses[][6] = {&quot;0&quot;};<br>Servo myservo;<br>typedef struct package Package;<br>Package data;<br>int val;<br>void setup()<br>{<br> Serial.begin(115200);<br> delay(1000);<br> myRadio.begin();<br> myRadio.setChannel(115);<br> myRadio.setPALevel(RF24_PA_MAX);<br> myRadio.setDataRate( RF24_250KBPS ) ;<br> myRadio.openReadingPipe(1, addresses[0]);<br> myRadio.startListening();<br> myservo.attach(9);<br>}<br>void loop()<br>{<br> if ( myRadio.available())<br> {<br> while (myRadio.available())<br> {<br> myRadio.read( &amp;data, sizeof(data) );<br> }<br> val = map(data.servo1, 0, 1023, 0, 180);<br> myservo.write(val);<br>delay(15);<br> }<br>}</blockquote>
<p>Also How do I order the 3D parts?</p>
ordering parts to print can be done on countless ways. but one i suggest is 3dhubs.com. You can have your print printed by someone Who is relatively close and is usually cheaper than havig it printed by a professional. Hope that helps!
you could use AA batteries, but I have noticed that they are not powerful enough. the only way I got it tonwork was with 2 battery packs with AA batteries, but in that case it was cheaper for me just to order the big batteries I use on te tank
<p>Also can I just use AA batteries.</p>
<p>does the Arduino nano come with a cord? where could I buy one?</p>
<p>Have checked and rechecked all connections. programs compile an load. Using a micro. Nothing happens, power lights up but nothing moves, tx and rx led's on micro do not show any action. Way ahead???</p>
<p>I think the problem lays with the wifi modules. I suggest using the Getting started guide in the library. this uses two way communictaion, so you know if the modules work. You might find <a href="http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo">this</a> site useful. In my code I actually changed pins 9 and 10 to 7 and 8 because The motor driver uses PWM. I had some trouble getting the modules working, but I messed around with it a bit and got them to work. I'm sure you'll be able to do the same!</p>
<p>with the joystick, which is the negative and positive leads?</p>
the joystick I use has pins on them that are labelled. so you should be able to tell on the joystick you use.
<p>Does the 12v on the motor driver connect to the same port as the switch? how do i do that?</p>
Hi,<br>The + of the battery connects to the middel pin of the switch. One of the outer pins of the switch connects to the +12V of the motor driver and the Vin pin of the arduino
<p>Arduino: 1.6.4 (Mac OS X), Board: &quot;Arduino Uno&quot;</p><p><em>Tank.ino:9:19: fatal error: RF24.h: No such file or directory</em></p><p><em>compilation terminated.</em></p><p><em>Error compiling.</em></p><p> This report would have more information with</p><p> &quot;Show verbose output during compilation&quot;</p><p> enabled in File &gt; Preferences.</p>
have you installed the RF24 library?
<p>could you include a link because i dont know where to look</p>
<p>in step 3 there is a file called RF24.zip. follow the instructions in step 3 to install that file and that should fix the problem.</p>
Ok. But then how do you connect both power sources to the same circuit?
well, one power source is used for the arduino and the other for the motors, so what you have to do is tie the ground wires of the power sources together creating a common ground and have one power lead run through the switch to Vin of the arduino and the other through the switch to the +12V of the motor driver.
Where did you get your power switches from?
<p>I bought them from ebay <a href="http://www.ebay.com/itm/10Pcs-AC-125V-6A-SPDT-3-Pin-On-On-2-Position-Miniature-Toggle-Switch-Blue-/171907590479?hash=item28067da94f:g:qT4AAOxykMpTGbfu">here</a>. but if you plan on using multiple power supplies(seperate ones for motors and arduino) you'll need something like this <a href="http://www.ebay.com/itm/10Pcs-AC-125V-6A-SPDT-3-Pin-On-On-2-Position-Miniature-Toggle-Switch-Blue-/171907590479?hash=item28067da94f:g:qT4AAOxykMpTGbfu">here</a></p>
How do you know what power supply to use and/or how many power supplies?
oh, sorry for the confusion. i meant battery packs. I only used one for the tank, but they are pretty powerful batteries. In that case you'd use the first power switch. If one choses to use a 4-6AA battery pack for the motors and a 9V battery for the arduino they should buy the second power switch
<p>I am using this module in this photo I use? the not work?</p>
<p>are you sure you wired it correctly? the pin with the square around it is pin 1. the one above that 2 and so on.</p>
<p>good day already tried all the connections are all well already checked several times and this as you have in the drawings</p>
hmm, thats odd.<br>maybe try the 'getting started' example included in the library. I found this site to be very helpful: http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo
Sorry its not a link, i'm on my phone at the moment

About This Instructable

10,165views

176favorites

License:

More by RyanKolk:Wireless Arduino controlled Tank (nRF24L01) 
Add instructable to: