Introduction: Raspberry Pi Cam Tank V1.0

Picture of Raspberry Pi Cam Tank V1.0

I love tanks since as a little kid. Building my own tank toy is always one of my dreams. But due to the lack of knowledge and skills. Dream is just a dream.

After years of study in engineering and industrial design. I acquired skills and knowledge. And thanks to the cheaper hobby 3D printers. I can finally take my step.

What features I want this tank to have?

  • Remote controlled
  • Suspensioned idle wheels(like the real tank!)
  • Has a rotatable turret and a tilting BB gun can shoot 6mm bullets
  • Can stream video to the controller so you can control it far away

In the beginning I planed to use arduino as controller, but after some research I found there's no practical way to stream video by itself. However, Raspberry Pi seems to be a good candidate for streaming video. And you can control it via wife from you phone!

Let's get started.

Step 1: Parts Needed

For controlling

Raspberry Pi version B

Powered Usb hub(Belkin F4u040)

USB webcam(Logitech C270)

Wifi dongle(Edimax)

Female to male jumper cable

For driving

Two high torque continues servo or motor(for two drive wheels)

One 1/8" steel rode for wheel shafts(bought at home depot and inexpensive )

Ten sleeve bearings (ordered on Mcmaster)

Some springs for suspension(bought a spring assortment at Harbor Freight, inexpensive)

For turret

A automatic BB gun toy

One high torque mini DC motor

A micro servo for tilting up and down

Some 1/4" steel rode as gun axle

Other stuff

I 3D printed most of parts of this tank, if you have easy access to a laser cutter, that would work too.

I used PLA filament for printing because it is easier to deal with(no wrap issues on ABS). But, really hard to sand, cut, drill later.

You might think 3D printing is good for customized parts and you can print very complicated part as one piece. That is true. However, I think that way is not practical and economical for a hobbyist. Reasons are:

Your hobby printer won't be that precise.

You will make mistakes in measurement and calculations(tolerance, alignment etc).

Anyway, there's a pretty high chance your prints do not work or fit on your first shot. It's fine for a small part, you can just change the model then reprint. But for a bigger and more complicated part, it is frustrating to know something's wrong after hours of printing. It's a waste of time and material. So here's my approach:

For anything is symmetrical, print only half of it, try it out, if everything works fine, print the whole thing.

Modeling the part while thinking about 3D printing. Could there be a flat surface to attach the printer bed?Could it be split into smaller pieces to avoid a lot supporting structure?

For parts have many features(interacting with many other parts), split the model into modules. So if one feature failed, you don't have reprint the whole part. Just tweak the module and reprint that. I use screws and nuts to connect them.

Be a good friend with hand tools, hand saw, X-acto, power drill, hot glue gun. If you can fix a mistake print, fix it.

This explains why my tank has so many parts. I am still tweaking those parts and once I found a good combination, I can print them together as one piece. Then that would be my Cam Tank v2.0.

Step 2: The Driving System


At first I made a prototype without any suspension, just axles across the lower hull with bearings and wheels. But thinking of the operator's comfort(I gonna drive it watching the streaming video!), I decided to add suspension to make it cooler.

All I have are some coil springs, no hydraulic, no leaf spring. I experimented some torsion bar mechanism with PLA at first. (Torsion bar suspension is common on some tanks). Turns out after a couple twist, the printed PLA bar would get soft and eventually break. ABS might be better for this purpose but I never tried. So, after further research, I found Christie suspension design , here's a short video shows how it works.

However, the christie suspension has so many small parts, and I have no confidence in my printer then. So I made some suspension like this.


This configuration occupies too much inner space. So I rotate the inner arm 90 degrees. Notice that the first and last wheel got a shorter

Rear tensioner

I thought when the tank running over some obstacles, idle wheels might move up and the track will lose tension. So I added some tensioner mechanism on the rear wheel. Basically it's two springs pushing the real axle all the time, exerting some force on it to tight the tracks.

Driving wheels and Tracks

I designed this caterpillar tracks and driving wheels in solidworks. I don't know much about mechanical engineering thus can not do the gear calculation. So I simulated parts in solidworks to see if it works before I hit the Print button. Each track is connected with some spare 3mm filament. It works pretty well with some sanding. But the track design has a flaw, the surface touching ground is too smooth that it is hard to grip. If I print it upside down, I could add some tread, but it will cost a lot supporting material because of the tooth. Future solutions: 1: print the tooth separately then glue them together. 2. Apply some rubber coating spray paint.

Then I printed the housing for servos and make sure the driving wheel can be attached to the servo arm with screws.

Step 3: Weapon System

This part is the most exciting for me. You can buy a camera tank toy. But I didn't find one toy combine camera and some weapon.

I bought this automatic airsoft gun toy for $9.99 on sale. (It's around 20 bucks now and I might try something cheaper later) And tear it down to understand the mechanism. I can totally cut the body and glue it to my tank. But I don't like the ugly looking half body. So I took some measurement and remodeled the mechanical part. From these pieces I learnt a lesson of 3D printing: you will always make mistake. It takes 5 prints to make every part fit, and a lot cutting, sanding and hot gluing to make it works perfect.

After every part from the toy gun move correctly in my replicated body, I printed four other parts to clamp the body. And added the tilting gear,BB bullet funnel and camera support. These parts are all screwed onto the gun body. Eventually they can be combined to at least two parts. But I think I am not ready yet.

On the turret base, I added a micro servo, for tilting, and a micro DC motor for rotation.

Then I started to test the gun, connect 4 AA batteries and it shoots well. I was really happy that it works well. But the next day I found a problem.

Here's the video of my gun testing. the turret was connected to a 3v adapter.

Step 4: Setup the Pi

This is the most important part, the heart of our tank--Raspberry Pi!

If you have't played Raspberry Pi yet. I recommend to start with this book: Getting started with raspberry pi by MAKE.You can get the basics and a comprehensive understanding of Pi.

Get the latest raspbian OS.

The next tool I recommend a lot is the Remote Desktop. Here's the tutorial by Adam Riley. After you set up, you can view Pi desktop on you PC(not tested on Mac). Thus to run the Pi "naked", means no need for a display,mouse and keyboard. Some of my friends are using ssh command line. But I prefer the desktop.

Based on previous research, I knew Raspberry Pi is capable to stream video. So I started to mess around with different apps on the Pi. Many of the apps either has a long lag(seconds) or has a low frame rate. After couple weeks of wandering on online videos and tutorials, luckily I found the solution. A video on youtube about webiopi gave me a lot hope. More research made me believe this is the right way to go.

Webiopi is a framework that made connection between Pi and other internet device really easy. It controls all the Pi GPIOS and then start a server contains customized html. You can gain access to this html from other devices(computer, smart phone, etc), and click a button in the browser in a wifi distance, a GPIO is triggered.

The video made me full of hope, is based on a webiopi tutorial--cambot project. It is featured on the MagPi magzine #9[html][pdf] and #10[html][pdf]. Thanks Eric PTAK!

By following the tutorial step by step, you can make to two wheel cambot! Here's how it works: connect two motor with a H-bridge, then control the H-bridge with 6 GPIO pins to control direction and speed. Webiopi is used to control the GPIOs. And MJPG-streamer is used for streaming video.

If you are new to the Pi or Linux as I was months ago, you may have a little problem after following all the steps. You can run the python code for webiopi and the streaming video separately but don't know how to run them together? It took me a while to know you can add a & after a command(& is really hard to search on google, BTW), that means you want this command run on the background. So I will do this every time:

sudo python

sudo ./

I believe you create a bash file containing above command into one file, and run once. I haven't tried yet.

So I tried this basic setup with two DC motor, it runs, but the motor I have is not powerful enough. Leads me to another option: continuous servos.

New question comes then: is webiopi supporting PWM controlled servos?

The answer is yes, but not by its self: RPIO is needed to generate software PWM

RPIO installation(I have no luck on the first apt-get install method. The github method works great for me)

Sample code and other discussions

Now your bot is upgraded with two servos! Think about what you can do with the extra arms!

I modified the above sample code to fit my tank. You don't need a computer science degree to do this. You are good as long you can understand the sample code and know what to copy and where to change.

Step 5: Electronic Connection

Picture of Electronic Connection

The power bank I bought, Anker Astro Pro, has two usb ports and one 9v port(main reason I bought this one). I tried to power the the Pi, wifi dongle and webcam with one usb port. Does not start up. So I used the other USB port for a powered USB hub.

Then I thought maybe I could power the servos with the USB hub port. It works, but the wifi connection is very very unstable.

To solve this problem, I brought in 4 AA battery to power the 6V servo needs. I striped the USB cable to expose the ground wire(black) and connect with the AA battery pack ground.

3 servos, red to 6V, black to ground, and signal pin connected to GPIO pins.

As planed, the turret rotating motor and gun motor should also powered by 6V with a H-bridge controlling. But when I connected everything, the gun won't shoot! It seems the motor is trying to rotate, but can't drive the gears. The output voltage is right, but seems there is no enough current to drive. I also tried MOSFET with no luck.

I have to give up this part for time reasons. And this is why in the gun test I have to connect the gun motor to adapter manually. Still a lot to learn in electronics. The worst case scenario, I could always control the gun with a servo pull and release trigger.

Step 6: Interface

Picture of Interface

I also altered the interfaces from the cambot and rasprover sample codes. Since I planned to use smart phone as controller, I optimized the layout for my phone(galaxy note3).

Most of the layouts and styles can be edited in the index.html. However the default button(dark grey with black border) style is defined in the webiopi.css located at /usr/share/webiopi/htdocs. I used terminal to run sudo nano in order to modified it.

The video stream is located in the center of screen, driving control on the left side, and weapon control on the right. I designed the driving control as two set of up(forward), stop, down(backward) wanting some finer control, but in the video you can tell it is awkward sometimes.

Step 7: Future Plan

As you can tell, this is project is not finished yet. Thanks to the raspberry pi contest, I cranked up a lot in last week, just trying to finish it before deadline. It turns pretty well until I found the gun's not shooting...

It has a lot more to be improved, but I hope you can learn something from my experience.

Short Term Plan:

Make the gun work!!!

Bigger container for more BB

The tank need to explore the world--go out side of home wifi!

Set up ad-hoc node on Pi, so the phone can connect to it anywhere

Run the tank command at start up

Add a shut down button to turn off Pi safely.

Long Term Plan:

Better driving system for stability and grip

Design my own circuit board instead of a breadboard now

First person video recording

Another gun? Let's make it a battle ship!

Add sensors for self patrolling?

Computer vision for auto targeting!

Control the tank far far away: I'll see everything at home!

Step 8: Thanks for Reading!

Thanks for reading my poor English(it's not my first language). I hope you had some fun or learnt something here. This will be an on-going project, so if you have expertise in any field, I appreciate your advise.

If you have any questions, please leave a comment, I'll try my best to answer it.

Let me make a update--The Cam Tank2.0-- in the near future.

At last, here's a video showing the battle scenario. It's quite amusing.

Enjoy and see you next time!


ValeriyM (author)2017-02-10

where can i find 3d models files for this tank?

AlexanderK139 (author)2016-11-10

Hello, I've been attempting to create a similar vehicle with arduino
but I've run into an issue with the canon portion of the build,
particularly the enclosure for all the moving parts. Do you happen to
have any tips for modeling the gun enclosure on the tank? Thank you in

datenkrieger (author)2016-10-10

Hi, I started with the installation on the Pi but it seems that RPIO doesn't support the Pi 2. Not sure if I can control servos with RPi.GPIO, any ideas?

Friedlc (author)datenkrieger2016-10-10

Hi datenkrieger, I realized this issue lately, too.

I have to look around for alternatives and I found this helpful:

Good luck!

datenkrieger (author)Friedlc2016-10-22

I found the pigpio library, it should work better with less servo jitter because it uses hardware timing for the pwm

Gaffkjn (author)2016-07-25

Hi Friedlc, awesome project. I enjoyed it immensely. Can you provide more detail for the shooting hardware. Specifically, I,m interested in HW you created around the two stage plunger system.




Friedlc (author)Gaffkjn2016-08-07

Hi Gaffkjn, you can find it here:

Friedlc (author)Gaffkjn2016-08-07

Hi Gaffkjn, you can find it here:

Friedlc (author)Gaffkjn2016-08-07

Hi Gaffkjn, you can find it here:

22181 (author)2016-06-12

Dude, that's so cool

Joey18brindle (author)2016-03-27

And you can control it via wife from you phone!?! Wow wish my wife coukd do things like that!

carter54 (author)2015-07-25

I really wanted to make this work as I have all the materials. But it is the wiring that stumped me. How to wire up the raspi to the controller to the motors on the breadboard. Tried to see if I could work it from the photo but no luck - can anyone point me to a diagram?

ghostlightcf (author)2015-03-22

Amazing build! Can you put up the 3D models for the whole turret assembly on thingiverse please? I have the exact same gun for a very similar project and I am having issues modelling it myself.

thegoatdoctor (author)2014-05-27

Good work! This is a great project, I stumbled upon it in my search for how to control an airsoft gun with Raspberry Pi since I'm doing a somewhat similar project. I don't quite understand HOW the Raspberry Pi controls the firing of the gun though, could you give me a little more detail please?

Friedlc (author)thegoatdoctor2014-05-29

Hi thanks! I was unable to control the gun electrically. I tried to connect the gun motor to the h-bridge or a mosfet. Both way didn't work. I think the gun motor just draws to much current for the h-bridge to handle, but it could be some error I made. In the videos I just plugged the gun directly to a 6v power source. A walk around is put another servo just pulling the trigger. You can take this instructable as reference.

MattTuck (author)Friedlc2015-02-14

Why not use a relay switch then? have the switch open/close wired to the bridge, and the power source to the gun.... then you could open and close the switch via your bridge, and thus fire the gun on command

marios8543 (author)2014-09-20

Dude like youre in my mind. I was thinking of making exactly the same thing but with rf and geared dc motors. Anyway that's great. In fact I'm making this right now.

webzter30 (author)2014-04-13

I still can't get the html file to open so I can copy and paste it, even in the RAR file. Is their a trick to it?



Friedlc (author)webzter302014-04-13

Here's all the code

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">



<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<meta name="viewport" content = "height = 300, width = 580, user-scalable = no" />


<script type="text/javascript" src="/webiopi.js"></script>

<script type="text/javascript">

function init() {

var button;

button = webiopi().createButton("bt_up", "/\\", go_forward, stop);


button = webiopi().createButton("gun_up", "/\\", servo_z_dim);


button = webiopi().createButton("bt_left", "<", turn_left);


button = webiopi().createButton("bt_stop", "X", stop);


button = webiopi().createButton("bt_right", ">", turn_right);


button = webiopi().createButton("bt_down", "\\/", go_backward, stop);


button = webiopi().createButton("gun_down", "\\/", servo_z_aum);


button = webiopi().createButton("servo_y_dim", "LU", servo_y_dim);


button = webiopi().createButton("servo_x_dim", "RD", servo_x_dim);


button = webiopi().createButton("servo_center", "0", servo_center);


button = webiopi().createButton("servo_centerX", "R0", servo_centerX);


button = webiopi().createButton("servo_centerY", "L0", servo_centerY);


button = webiopi().createButton("servo_x_aum", "RU", servo_x_aum);


button = webiopi().createButton("servo_y_aum", "LD", servo_y_aum);


button = webiopi().createButton("fire", "F", fire);


button = webiopi().createButton("stop_fire", "S", stop_fire);



function go_forward() {



function go_backward() {



function turn_right() {



function turn_left() {



function stop() {



function servo_y_aum() {



function servo_y_dim() {



function servo_x_aum() {



function servo_x_dim() {



function servo_z_aum() {



function servo_z_dim() {



function servo_center() {



function servo_centerX() {



function servo_centerY() {



function fire() {



function stop_fire() {





<style type="text/css">

button {

margin: 5px 5px 5px 5px;

width: 50px;

height: 30px;

font-size: 18pt;

font-weight: bold;

color: black;



input[type="range"] {

display: block;

width: 160px;

height: 45px;












<table width=550px>


<div id="su"></div>

<div id="medioY"></div>

<div id="giu"></div>



<div id="RU"></div>

<div id="R0"></div>

<div id="RD"></div>


<td id="spacing">

<img src="http://raspberrypi:8001/?action=stream" width="320" align="center">

<div id="middle" align="center"></div>



<div id="content" align="center">

<div id="gunup"></div>

<div id="gundown"></div>

<div id="fire"></div>

<div id="stopfire"></div>





Friedlc (author)webzter302014-04-13

maybe you can try to open it with a text editor?

webzter30 (author)2014-04-05

could you send me a link to the html file for you bot. I can't get it to open.

it says forbidden.



Friedlc (author)webzter302014-04-06

I re uploaded the .html file and it does not work for some reason. But you should be able to open it in the .rar file I just uploaded. Let me know if you have other questions.

dnicol1 (author)2014-04-05

Sure Fried. Give me a call at 647-984-4314. Thanks David

Friedlc (author)dnicol12014-04-05

went to voice mail directly. can we do a google hangout or skype?

dnicol1 (author)2014-04-04

Hi there . Loved your instructables. Would you be interested in a paid project ??

Friedlc (author)dnicol12014-04-04

Sounds interesting. Can you send me some details?

adillbeck (author)2014-02-11

Controlling things by wife never seems to work for me.

"Wife, please turn on the tv and change it to CNN"

"No, I'm watching Hallmark, and I have the remote, so there"

Friedlc (author)adillbeck2014-02-18

Haha, that's hilarious, I spotted that mistake, but think it's fun leaving it there.

TSJWang (author)2014-02-04

That awkward moment when you have a suprisingly similar project as someone else...

Friedlc (author)TSJWang2014-02-06

Maybe we should build something bigger together!

TSJWang made it! (author)Friedlc2014-02-06

How is it possible that we used the same webcam, WiFi device, library, webcam, and battery?!

It was destiny

I think its appropriate to say "I Made it!"

Friedlc (author)TSJWang2014-02-18

That's awesome, we should have a battle!

audreyobscura (author)2014-02-04

Great work! Totally Rad! You should include your .stl files for your tank!

Friedlc (author)audreyobscura2014-02-04

Thanks! I have too many parts need to be modified and simplified. I'll upload the parts for my next update for sure! Do you need any of the specific parts so that I can share with you?

samern (author)Friedlc2014-02-06

If you are willing to share, the turret parts would be useful. I have several tanks that I have built that either take the Pi or the Arduino, but turret would save me some time. For axles and torsion bar suspension ABS might last longer than PLA but will eventually fatigue as well. One way is to use rubber bands (I seem to recall something like that on a tank I built as a boy). The end of your torsion bar would need a hook or loop through which you would put in a doubled up rubber band that that would hold your axles up with sufficient tension. It does mean making room in your chassis for it though.

Friedlc (author)samern2014-02-06

Hi I uploaded the turret gear and ring on thingiverse.

It's not perfect design cos I don't know how to do the calculation.

Hope it can help on your projects. Let me know if you need anything else.

Rubber band sounds doable. Let me try it next time, thanks!

samern (author)Friedlc2014-02-06

Excellent thank you. I have a 'heavy duty' airsoft gun that is dying to be transferred to bot and a nice turret, camera and laser sight would make it possible to point and shoot at the target with some accuracy!

audreyobscura (author)Friedlc2014-02-04

When they are ready, it's a well designed tank tread, nice parts to have on-line.

Friedlc (author)audreyobscura2014-02-06

Hi the track and driving wheel parts are uploaded on thingiverse.

Let me know if you need anything else!

epierce (author)2014-02-04

I too am working on a 2 wheel bot. It has a raspberry pi, connected to an arduino, then a motor control. The plan is to operate the drive motors and everything at 12 volts! You could use a car usb charger (aka cigarette lighter) to drop the voltage to your equipment.

I have been able to interface pi and the motor control (minus camera and bb gun) to operate remotely from my Windows7 netbook but have yet to get an Android tablet to work, any suggestions?


Friedlc (author)epierce2014-02-06

Oh I never thought of using the charger to drop voltage. Should be a easier solution than 7805 or LM317. Maybe it is because of browser? I am using latest chrome on my phone. Hope this help.

Droxz (author)2014-02-04

amazing job, keep up the good work!

Friedlc (author)Droxz2014-02-06

Thanks! :D

bricobart (author)2014-02-04

Impressive work - I look forward to see the flamethrower version ;)

Friedlc (author)bricobart2014-02-06

That sounds awesome! on my list!

awang18 (author)2014-02-05

I work with this guy and he ate my sandwich. Chen, you owe me a sandwich.

awang18 (author)awang182014-02-05

Now he wants to eat my donuts.

Misac-kun (author)2014-02-04

Your English is pretty well for me. Also, very good and documented 'ible!

Friedlc (author)Misac-kun2014-02-04

Thanks a lot! Hope you had fun reading it :)

About This Instructable




Bio: A Interaction Designer with Industrial Design and EE background. Maker since a kid. Super grateful to new technology and online communities made everything possible!
More by Friedlc:2.5D Edge Lighting Pixel LED CubeRaspberry Pi Cam Tank V1.0
Add instructable to: