Introduction: Tiny Smartphone Controlled Arduino Tank

Picture of Tiny Smartphone Controlled Arduino Tank

In this Instructable I'll show you how to make a very small smartphone controlled arduino tank.

I tried to make the TinyTank as small as possible, I also wanted to control it with a smartphone.
At least I wanted to make it easy to disasemble so I can try out other controls like IR and 2.4GHz.
I will explain stap by stap how I made it and I will share the code and schematics so you can make it to.


I came up with the design myself.

Step 1: What You Will Need

Picture of What You Will Need

Parts:
2x 9g fullyrotational servo. Here is my Instructables for that: Fullyrotational-Servo
1x Bluetooth module (hc-06)
2x 5mm white LEDs
2x 5mm red LEDs
1x Arduino nano
1x Perfboard (at least 31x24holes or 15x49 holes)
3x aaa batterys to power the TinyTank
1x Boost module (3,5/4,5volt - 9 volt)
1x A little gun or something simular(optional) I have mine from an old rc helicopter I think.
2x 100 ohm resistors
1x 1K ohm resistor
1x 47 ohm resistor
1x BC547 (NPN) Transistor or simular
about 56x small lego tracks
4x 26 tooth LEGO gears
2x lego part: 4526985
2x lego part: 4512363
2x lego part: 4142865
2x lego part: 4206482
1x small switch
3x little springs
1x passive buzzer
Some wires
A lot of female headers
A lot of male headers
Some pieces of headschrinktube
A little thin piece (about 4 cm x 4 cm) of sheet metal (you have to be able to solder it)


Tools:
Soldering iron
Pc with Arduino IDE
Glue gun
Helping hand
A smartphone with Android
Double sided tape
Duct tape
Knife
Pliers
Scissors

Step 2: Prepairing the Headers and the Perfboard

Picture of Prepairing the Headers and the Perfboard

Cut your female headers in to pieces of:
2x 15 Pins
2x 24 Pins
2x 4 Pins
1x 2 Pins
2x 13 Pins
4x 1 Pin

Cut your male headers in to pieces of:
2x 9 Pins
2x 24 Pins
2x 4 Pins

Cut your Perfboard in to two pieces of 15 By 24 Holes


Now solder a female header of 4 pins to a male header of 4 pins in a 90 degree angle and a 4 pins female to a 4 pins male without an angle and put some heatschrinktube around it like the pictures.
I will tell you later where this is for.

Step 3: Making the Battery Parts

Picture of Making the Battery Parts

Now we are going to make the little springy things that will hold the batterys in place.

Take your sheet metal and cut two pieces of 2 cm by 0,8 cm and two pieces of 1 cm by 1,5 cm (these measurments are very important)
take the piece of 2 by 0,8 and cut a cross at one end like the pictures.
Now bend two of the four triangels and place the spring between them.
Bend the triangels back in place and make sure the spring is secure, I soldered it from the back aswell. Do this twice.

Now take one of the smaller pieces and cut it at 8 mm but leave a small soction of about 1,5 mm wide on.
Now make a cross again and secure the spring like the other one.
Make the 1,5 mm piece thinner and stronger with pliers (make sure it fits into the perfboard).
Now tin the little pin you just made and solder the spring from the back in place (watch the pictures for better detail).
Do the same with the other metal piece but don't attach a spring.

Step 4: Prepare the Servos

Picture of Prepare the Servos

I had this idea from: Servo-motor-Adapted-to-Lego .Take a fullyrotational servo and cut a cross in the rotating part and make sure a lego part can fit on. Next cut the lego parts with the cross in them to 11 mm. Now take that piece and put a screw in it and screw it on to the servo(make sure you put the screw in the long part of the lego piece) and try to get it as straight as possible. To finish the servo cut the sides of.
Repeat that for the other one aswell.

Step 5: The Drive System

Picture of The Drive System

First take one piece of the perfboard you cut earlyer and solder the 24 pin and 13 pin female headers on to it as shown. Now it is time to solder on the switch and glue and solder the metal pieces, make sure the posititive plate (the one without spring) is on the side with the switch. Solder a wire from the positive plate to the switch and from the center pin of the switch to the left under pin. Connect the negative plate to the sixth pin. Cut the red wire of a servo to 2,5cm and connect it to the second pin, the brown wire to 3cm and connect it to pin 6 and the yellow wire to 7,5cm and connect that one to pin 21 of the other side. Take the other servo and cut the red wire to 8cm and connect it to the second pin, the brown wire to 8cm and connect it to pin 6 and the yellow wire to 2cm and connect it to pin 22 (you can better cut them a bit to long than to short). That was all the soldering for the drive part, when you are sure the connections are right you can use a bit of glue to fix them in place, be sure to glue them in the center and as close to the end as possible. To test it you will have to connect a jumper wire to the two pins next to the switch and insert the batterys. When you flick the switch the servos should turn very short. Now you know it works you can use hot glue to secure them and attach the two lego pieces as shown, make sure you won't cover the hole in the servo.

Step 6: Making the Shield

Picture of Making the Shield

The shield is the piece that will hold the arduino, the Bluetooth module, the LEDs, the buzzer and the boost converter. It will go on top of the drive part.

Take your other piece of perfboard and solder male headers to the sides and connect the left back two pins as shown. Now solder 15 pin long female headers on top so the arduino nano can fit, make sure the two connected pins are not next to them. (Check the pictures)
Now solder 4 female headers to the back so you can fit in your boost converter later. Connect pins 9 and 10 to the pins next to them using some short wires. Solder the positive and negative female header of the boost converter to the pins next to them and solder the output negative female header to a ground pin of the arduino and the positive to the vin pin of the arduino. Next solder on the extra long straight header behind the arduino and connect vcc of the Bluetooth module to 5volt, ground to ground and tx of the module to rx of the arduino. Now we are going to connect the lights. First solder on the red leds on the back and connect the negative and the positive leads of the leds to each other and connect negative to ground with a 100 ohm resistor and positive to pin 2 of the arduino. Now solder on the white leds on to the perfboard and connect the positive leads and negative leads to each other again. To finish this part you will only have to connect the negative of the leds to ground and the positive with a 47 ohm resistor to pin 8 of the arduino and connect the buzzer (it has polarity) to pin 6 and with a 100 ohm resistor to ground.
Now stick a piece of tape on the bottom and your shield is done if you don't have a gun for it. If you have one you will have to follow the next step.

Step 7: Connect the Gun (optional)

Picture of Connect the Gun (optional)

We have to solder some more components to connect the gun.
Like the transistor, the resistors and the 2 pin female header.

First solder on the 2 pin female header and the bc547 transistor next to it with the flat Side towards the headers for the arduino. Now solder the middel (base) pin of the transistor with a 1K ohm resistor to pin 3 of the arduino and the left pin (the emitter) of the transistor to the right pin of the female header. The only thing left to do is connecting the right pin of the transistor (the collector) to the about 4 volts positive of the batterys and the left pin of the 2 pin female header to ground.
Now everything is done we can assemble the TinyTank and give it a try.

Step 8: Connect Everything

Picture of Connect Everything

First gather all the parts and make sure there are no short circuits. Take the four gears and stick in the lego pins. Now connect the gears to the drive part and snap on the tracks. Insert the batterys and press the shield on. Now you have to make sure the boost converter is set to 9 volts, or an other voltage in the range of the arduino, and plug it in the right way so the input is connected to the batterys. Plug in the arduino, the 90 degree elbow and the Bluetooth module. If you have the gun you can stick it on the boost converter with a piece of double sided tape and connect it, polarity does not matter the gun will just simply turn the other way around.
Do not flick the switch just yet.

Step 9: The Code and the App

Picture of The Code and the App

I hope you enjoyed the build as much as I did. Now you only have to program the TinyTank and it is ready for the first test drive.
The Bluetooth module will mess up the programming so you have to unplug the Bluetooth module before uploading anything.

So, to upload the code, disconnect the Arduino(I don't know what happens if you leave it in so just take it out), plug in a usb cable and copy and paste the code from here into the Arduino IDE. Make sure you select the right arduino and com. Now upload the code.

You can copy the code from here:

TinyTank code:
It will receive the data from the Bluetooth module and drive the little tank forward backward left and right. It will also fire the gun and turn the lights on and off when you press the buttons on the app and you can set the speed from the app. It beeps when started up and when the connection is lost.

-----------------------------------------------------------------------------------------------------------------------------------------
/* this sketch will drive the TinyTank with bluetooth.
* When you turn it on it will make a sound and if you disconnect it it will make an other sound and
* the lights will blink twice.
* It is obvious that when you press the forward button on the app that the tank will drive
* forward and so on. When you press the button for the headlights the headlighst will turn on,
* and this is the same for the backlights. when you press the horn button the horn will turn on
* and if you press again it will turn off. When you press the triangle button the gun will fire once.
* you can change the speed the tank will drive by sliding the slide back and forth.
*
* the only thing you will have to change is the time the gun is set high so it will shoot once, it will
* depend on your type of gun.
*
* Made by: Ynze Selders
*/


#include


int rSpeed=0;
int lSpeed=0;
Servo rightservo;
Servo leftservo;
char command;
const int headLights = 8;
const int backLights = 2;
const int gun = 3;
const int buzzer = 6;

void setup() {
Serial.begin(9600);
rightservo.attach(9);
leftservo.attach(10);
pinMode(headLights, OUTPUT);
pinMode(backLights, OUTPUT);
pinMode(gun, OUTPUT);
pinMode(buzzer, OUTPUT);
rightservo.write(90);
leftservo.write(90);

tone(buzzer, 750); //startup tone
delay(150);
tone(buzzer, 1000);
delay(150);
tone(buzzer, 1250);
delay(150);
noTone(buzzer);

}

void loop() {
if(Serial.available() > 0){
command = Serial.read();
Stop();

switch(command){ //these are all the letters and numbers the app sends to the bluetooth
case 'F': //module
forward();
break;
case 'B':
back();
break;
case 'L':
left();
break;
case 'R':
right();
break;
case 'G':
forwardleft();
break;
case 'I':
forwardright();
break;
case 'H':
backwardleft();
break;
case 'J':
backwardright();
break;
case '0': //these are the different speeds
rSpeed=85;
lSpeed=95;
break;
case '1':
rSpeed=83;
lSpeed=97;
break;
case '2':
rSpeed=81;
lSpeed=99;
break;
case '3':
rSpeed=79;
lSpeed=101;
break;
case '4':
rSpeed=77;
lSpeed=103;
break;
case '5':
rSpeed=74;
lSpeed=106;
break;
case '6':
rSpeed=70;
lSpeed=110;
break;
case '7':
rSpeed=65;
lSpeed=115;
break;
case '8':
rSpeed=59;
lSpeed=121;
break;
case '9':
rSpeed=25;
lSpeed=155;
break;
case 'q':
rSpeed=0;
lSpeed=180;
break; //end of the speeds
case 'W': // if headlightbutton is pressed turn headlights on
digitalWrite(headLights, HIGH);
break;
case 'w': // if headlightbutton is pressed again turn headlights off
digitalWrite(headLights, LOW);
break;
case 'U': // if backlightbutton is pressed turn backlights on
digitalWrite(backLights, HIGH);
break;
case 'u': // if backlightbutton is pressed again turn backlights off
digitalWrite(backLights, LOW);
break;
case 'X': // if gun button is pressed shoot once
digitalWrite(gun, HIGH);
delay(150); // tweak this value so it shoots once if you press the button
digitalWrite(gun, LOW);
break;
case 'x': // this is the same as the one above here but otherwise you had to press the
digitalWrite(gun, HIGH);//button twice to shoot once
delay(150); // so tweak this value to the same value as the other one
digitalWrite(gun, LOW);
break;
case 'V': // if the horn button is pressed turn the buzzer on
tone(buzzer,1000);// modify this value to get other tones
break;
case 'v': // if the horn button is pressed again turn the buzzer off
noTone(buzzer);
break;
case 'D':
rightservo.write(90); //if disconected turn motors off
leftservo.write(90);
digitalWrite(gun, LOW); //if disconected make sure the gun is off
tone(buzzer, 2000); //if disconected blink lights and make sound
digitalWrite(headLights, HIGH);
digitalWrite(backLights, HIGH);
delay(250);
digitalWrite(headLights, LOW);
digitalWrite(backLights, LOW);
delay(250);
digitalWrite(headLights, HIGH);
digitalWrite(backLights, HIGH);
delay(250);
digitalWrite(headLights, LOW);
digitalWrite(backLights, LOW);
delay(250);
noTone(buzzer);
break;
}
}

}

void forward() //define what is forward
{
rightservo.write(rSpeed); //it moves with the speed you selected in the app
leftservo.write(lSpeed);
}

void back() //define what is backward
{
rightservo.write(lSpeed);
leftservo.write(rSpeed);
}

void left() //define what is left
{
rightservo.write(rSpeed);
leftservo.write(rSpeed);
}

void right() //define what is right
{
rightservo.write(lSpeed);
leftservo.write(lSpeed);
}

void forwardright() //define what is forwardright
{
rightservo.write(90);
leftservo.write(lSpeed);
}

void forwardleft() //define what is forwardleft
{
rightservo.write(rSpeed);
leftservo.write(90);
}

void backwardleft() //define what is backwardleft
{
rightservo.write(90);
leftservo.write(rSpeed);
}

void backwardright() //define what is backwardright
{
rightservo.write(lSpeed);
leftservo.write(90);
}

void Stop() //define what is stop
{
rightservo.write(90);
leftservo.write(90);
}
-------------------------------------------------------------------------------------------------------------------


The app:
https://play.google.com/store/apps/details?id=braulio.calle.bluetoothRCcontroller&hl=nl

Step 10: Finished Product

Picture of Finished Product

Now your TinyTank is done, you can start playing with it and maybe improve it.
To connect it with your phone, turn the TinyTank on, you should hear a beeping sound, go to the app and click the gear, connect to car and connect to it with the code 1234 or 0000. If the red light turns green it is connected. Now you can start driving.
I would like to hear it if you made the TinyTank.

I posted a video on Youtube, you can click on this link if you want to see it in action:

TinyTank

I will maybe make an other shield with a NRF24L01 module in the near future to make it 2.4GHz controlled.

Ask my in the comments if you have any questions.

Comments

Ynze- (author)2016-03-25

Thank you

srijan sehdev (author)2017-06-21

can a l9110 motor driver be used with this project

srijan sehdev (author)2017-05-24

#include <nano tank>

int rSpeed=0;

int lspeed=0;

Servo rightservo;

Servo leftservo;

void setup(){

Serial begin(9600);

rightservo.attach(11);

leftservo.attach(10);

rightservo.write(90);

leftservo.write(90);

}

void loop (){

if(serial.available()>0){

command=Serial.read();

stop();

switch(command)//these are the letters and numbers that app sends to the bluetooth module

case'F':

forward();

rspeed=200;

lspeed=200;

break;

case'L':

left();

break;

case'R':

right();

break;

case'D'

rightservo.write(90);//if disconnect turn motors off

leftservo.write(90);

break;

}

}

void forward()//define what is forward

{

rightservo.write(rspeed=200);

leftservo.write(lspeed=200);

}

void back()//define what is backward

{

rightservo.write(lspeed);

leftservo.write(rspeed);

}

void left()//define what is left

{

rightservo.write(rspeed);

leftservo.write(rspeed);

}

void right()//define what is right

{

rightservo.write(lspeed);

leftservo.write(lspeed);

}

void stop()//define what is stop

{

rightservo.write(90);

leftservo.write(90);

}

are these codes correct?

srijan sehdev (author)2017-03-13

what if i connect the servo signal wire to the wrong digital pin???

Ynze- (author)srijan sehdev2017-03-13

The Servo motor wont work then, but If you change the code it Will work fine on a different digital pin.

srijan sehdev (author)Ynze-2017-03-14

Thanks alot

srijan sehdev (author)2016-06-20

What if i connect bluetooth module directly to power source ?will it work

Ynze- (author)srijan sehdev2016-06-20

The voltage range on the Bluetooth module is from 3,6 to 6 volts. The power source are 3 rechargeable 1,2 volt batterys so that's 3,6 volts but if the batterys get low it will drop below 3,6 volts so you will need to use non rechargeable 1,5 volt batterys for it to propperly work so that is why I connected it to the 5volt pin of the arduino.

srijan sehdev (author)2016-06-14

i just wanted to ask that how much GHz is it

Ynze- (author)srijan sehdev2016-06-14

It is a Bluetooth device and Wikipedia says that Bluetooth works with 2.4 to 2.4835 GHz.

Sarvasv Kulpati (author)2016-04-03

does the app work with iphone as well?

Ynze- (author)Sarvasv Kulpati2016-04-03

unfortunately not

eliesalame (author)2016-03-30

Nicely done, thank you

Stap to Stap?

Stap to Stap?

stitchman (author)2016-03-28

where would I be able to find the requirements

sukuakku (author)2016-03-25

great design.

About This Instructable

6,346views

180favorites

License:

More by Ynze-:Electric LighterTiny 80Watt Electric HeaterTiny Smartphone Controlled Arduino Tank
Add instructable to: