iPhone Controlled Tank
iPhone Controlled Tank
Solar Panel Charger
Using the super awesome TouchOSC app for the iPhone connected to Processing for converting Open Sound Control signals into serial commands send out via USB to an Xbee...I am able to drive a small tank.

The tank is entirely made from SparkFun parts:
Dual Motor GearBox
Stackable Arduino Headers
Super Awesome Tank Treads
LiPoly Battery Charger
Small Solar Panel
XBee USB board
XBee Explorer board
Also used a number of misc jumper wires, rubber bands, a block of wood and a few small pieces of aluminum (from the back of a PC).

Of course you will need an iPhone to get everything running exactly as I have setup, but you don't need to use an iPhone to control your tank, you could use a midi controller, a multi-touch screen, a random hardware controller, or really anything that can send serial, OSC or anything into Processing.

Here is the Source Code:
Source code for Arduino is from a Mechomaniac.com:

//-----------Start Arduino code ---------------

// Test program for SparkFun Ardumoto board
// Copyright (c) 2009 mechomaniac.com
// To use, connect the Arduino to a computer and send commands using a serial terminal.
// eg AR40#   motor A forwards with a speed of 40
#define PwmPinMotorA 10
#define PwmPinMotorB 11
#define DirectionPinMotorA 12
#define DirectionPinMotorB 13
#define SerialSpeed 9600
#define BufferLength 16
#define LineEnd '#'
char inputBuffer[BufferLength];
void setup()
  // motor pins must be outputs
  pinMode(PwmPinMotorA, OUTPUT);
  pinMode(PwmPinMotorB, OUTPUT);
  pinMode(DirectionPinMotorA, OUTPUT);
  pinMode(DirectionPinMotorB, OUTPUT);
// process a command string
void HandleCommand(char* input, int length)
  if (length < 2) { // not a valid command
  int value = 0;
  // calculate number following command
  if (length > 2) {
    value = atoi(&input[2]);
  int* command = (int*)input;
  // check commands
  // note that the two bytes are swapped, ie 'RA' means command AR
  switch(*command) {
    case 'FA':
      // motor A forwards
      analogWrite(PwmPinMotorA, value);
      digitalWrite(DirectionPinMotorA, HIGH);
    case 'RA':
      // motor A reverse
      analogWrite(PwmPinMotorA, value);
      digitalWrite(DirectionPinMotorA, LOW);
    case 'FB':
      // motor B forwards
      analogWrite(PwmPinMotorB, value);
      digitalWrite(DirectionPinMotorB, LOW);
    case 'RB':
      // motor B reverse
      analogWrite(PwmPinMotorB, value);
      digitalWrite(DirectionPinMotorB, HIGH);
void loop()
  // get a command string form the serial port
  int inputLength = 0;
  do {
    while (!Serial.available()); // wait for input
    inputBuffer[inputLength] = Serial.read(); // read it in
  } while (inputBuffer[inputLength] != LineEnd && ++inputLength < BufferLength);
  inputBuffer[inputLength] = 0; //  add null terminator
  HandleCommand(inputBuffer, inputLength);

//----------- End Arduino code ---------------

Processing code:

//----------- Start Processing code ----------------

import oscP5.*;
import netP5.*;
import processing.serial.*;
Serial arduinoPort;
OscP5 oscP5;

float [] fader = new float [3];

void setup() {
  oscP5 = new OscP5(this,8000);
  arduinoPort = new Serial(this, Serial.list()[0], 9600);

void oscEvent(OscMessage theOscMessage) {

    String addr = theOscMessage.addrPattern();
       if(addr.indexOf("/1/fader") !=-1){
       String list[] = split(addr,'/');
     int  xfader = int(list[2].charAt(5) - 0x30);
     if(theOscMessage.get(0).floatValue() !=0){
     fader[xfader]  = theOscMessage.get(0).floatValue();

void draw() {
//---------------------------------Motor A
 if(fader[1] > 0.65){
   if(fader[1] < 0.35){
  //--------------------------------Motor B
   if(fader[2] > 0.65){
   if(fader[2] < 0.35){
  //----------------------------stop commands
     if(fader[1] < 0.65 && fader[1] > 0.35 ){
       if(fader[2] < 0.65 && fader[2] > 0.35 ){

//---------------------- End Processing Code ------------------


11/28/2009 21:26

Incredible project! I've been a picaxe guy since I started in electronics (actually I started with a BASIC Stamp. I know, I'm trying to forget ;)), but seeing all these Arduino projects makes me really want to buy one.


12/03/2009 12:45

really really nice for you to share the code and prototipe such a clear-designed object.



12/03/2009 12:59

Very nice. The parts list was nice to see and the robot looks really well made. Good job

12/04/2009 03:17

Saw your video from The iPhone Blog! Great job, i'm always impressed by developers that can do this kinda work!

Keep it up,
- MexiChriS

Davd Z
12/04/2009 04:09

Awesome. You should consider selling these. I have no idea if this is realistic, but I'd buy one if it could be made for less than $100.

David Z
12/04/2009 04:11

Just saw the prices on the parts list... at least $200 in parts. Oh well.

12/04/2009 06:23

This is part of a larger project which involves motion tracking robots virtually firing projections... and you don't need all of this stuff to make an iphone controlled tank. I'll try to make a cheaper version.

Ardy Hash
12/04/2009 09:05

12/04/2009 09:11

pretty neat, but have you checked out the various routerbot projects? using an off the shelf wireless router, two continuous rotation servos, and a serial servo controller i was able to achieve the same, minus the cool tank treads. my point being that my project cost less than $100, and can be controlled with any web-enabled device (control is through an html webpage hosted on the router, with an internet connection it can be controlled from, well, the internet!)

12/04/2009 09:40

David and Ardy, it could easily cost less than $100, for me I had all of these parts laying around. I'm sure there are a number of cheaper ways to do exactly the same thing.

Also this is just one piece of my project, I'll post more about it later tonight or tomorrow.

12/04/2009 12:51

So the wireless goes from the iphone to the laptop to usb to wireless to the xbee on the tank? Could it be done without the laptop, if the tank has wifi like http://www.sparkfun.com/commerce/product_info.php?products_id=9333 ???

12/04/2009 17:15

John, Yes it could be done without the laptop, however I'll be using the signals send from the iPhone in Processing to do other things...see my latest post to get an idea of what I'm talking about.

12/07/2009 11:09

Chris, no need to get defensive, these are valid comments. I get that this is a part of a larger project, but in general there are better and much cheaper ways of building a wirelessly controlled (or iPhone controlled) tank/robot.

12/08/2009 14:40

I am real interested to hear ideas for how it could be done without the laptop!

I see how you could use the WiFly to pull down web data. But the TouchOSC interface is so much nicer than a web interface. Is there some way that the Arduino could receive OSC over wifi directly?

12/08/2009 14:56

Yes it could be done without the laptop by using the WiFly...in fact it would be very similar to the how the Electro-Luminescent suit control system was created in my other blog post.

12/09/2009 11:59

Really a good job!
one question:
what kind of program did you use to programe the tank.

12/09/2009 12:08

I used Arduino. www.Arduino.cc

12/11/2009 12:17

Are there any other iphone apps like touch osc, but a little more generic way to send data over wifi via a custom gui (other than writing your own app)?

03/07/2012 20:20

Their are a couple for the iPhone, iPad, and iPod touch they are MrMr, and RemoteOSC. MrMr is very buggy but I would stick with what you got.

12/11/2009 12:28

That's a good question John. I'm not sure, but that would be nice. If you hear of anything, let me know.

I haven't found any other apps that even come close to the interface builder of TouchOSC, and since I'm familiar with OSC it's been a great tool.

12/15/2009 13:23

can I use easyC fro Vex to program the tank

12/30/2009 14:38

you said: "Yes it could be done without the laptop by using the WiFly..."

could you give a bit more info? I'm thinking of using the WiShield (http://www.asynclabs.com/store?page=shop.product_details&flypage=flypage.tpl&product_id=17&category_id=6) to send OSC data from TouchOSC directly to the Arduino. But how will the Arduino be able to read the incoming OSC data? I found an OSC library for EthernetShield (http://blog.makezine.com/archive/2009/03/osc_library_for_arduino.html), but would this also work with WiShield or WiFly? If so, does it require any modifications?

Thanks for the help

01/19/2010 12:00

Chris can i use some tires instead of the tank rials. or how does that affect the robot endurance?

01/29/2010 12:38

Am new to this ...........i want to learn more.and really want to build this tank ....i know i could get the parts.. dont know which wire goes wehere... you think u could help me with that .... one day i could build something of my own .. keep up the good work peace....

01/31/2010 11:44

I have been looking to construct a hardware system design that can recieve a signal from a 3g or 4g network, and pretty much go anywhere a telephone can go. The routerbot is cool because of the range that it has and the bandwidth it can pump out means it can handle a live video feed from a camera.

If anyone has any ideas how such a system as the one i have in mind can be implemented. I'd be curious to know, But I doubt that the darn thing can support the video feed that it would need to have unless the video quality suffered.

02/17/2010 13:38

one question; how you programed the arduino without using the usb cable.

03/11/2010 03:26

Nice job! Glad to hear my gearbox isn't the only one that sounds like that! Thanks for the code.

04/12/2010 23:29

Congratulations for the project.
I'm starting now and let me know if you have the wiring diagram of the components of the wagon.
Thank you.

04/15/2010 04:57

hello, your work has been my inspiration



Scott Portocarrero
06/19/2010 10:49

Awesome project!!! Do you have a copy of your OSC interface. I tried making one but not sure what your fader addresses are.

07/11/2010 17:08

pretty much go anywhere a telephone can go.

07/24/2010 07:49

How many batteries are you using to power this tank?

09/01/2010 15:29

hey thats cool
can u jus explain me how to give all the connections

10/14/2010 14:56

Hi there, love this project, trying to get this to work with one of my bots, testing to see if it can turn a led on with and fade it, but all i get is
"### [2010/10/14 23:0:43] ERROR @ OscP5 ERROR. an error occured while forwarding an OscMessage
to a method in your program. please check your code for any
possible errors that might occur in the method where incoming
OscMessages are parsed e.g. check for casting errors, possible
nullpointers, array overflows ... ." messages.... any help would be great, thank you.

Also is there a tutorial for this project? thanks. great job

11/15/2010 12:04

It's so interesting. Is it for Android. Actually phone should be only phone , not weapon.

12/08/2010 16:12

Anyone know where we can buy this tank?

01/20/2011 00:18

Skiing.Stylish Spyder Jacket May Surprise You Thomas Sabo Charms.Spyder Jackets Create A mor beautiful Look.Thomas Sabo Ohrschmuck Keeps You Warm.When buying a spyder ski wear Thomas Sabo Ketten Bänder, it is very important to know the quality of the thomas sabo charm club products that you are going to thomas sabo outlet.When buying a spyder ski wear

01/20/2011 06:29

Hello friends,this is a nice site and I wanted to post a note to let you know, good job! Thanks
Best regards, Natali, CEO of <a href="http://www.starburnsoftware.com">iso burner</a>

01/20/2011 06:30

Hello friends,this is a nice site and I wanted to post a note to let you know, good job! Thanks
Best regards, Natali, CEO of [url=http://www.musicfrost.com]free music downloads[/url]

01/21/2011 21:34

Great ... loved it!!! will be waiting for your future posts!!
Thanxxx for sharing this knowledge !! :)

01/24/2011 08:19

Keep up on it. Thanks for sharing the info

02/01/2011 12:21

Hello here! I really enjoy reading your blog! If you keep making great posts I will come back every day to keep reading!

02/10/2011 03:11

its very nice and amazing project.

02/13/2011 21:36

Hi, i have an R/C car that has a Electronic Speed Control and a servo. I was wondering it possible to do this project with those items? Thanks and great work!

02/15/2011 23:51

Awesome. You should consider selling these. I have no idea if this is realistic, but I'd buy one if it could be made for less than $100.

03/02/2011 14:30

That is the coolest looking iphone controlled robot I have ever seen. Robotics is sooo cool!! I just hope they don't try to take over like in the future.

Alex V
03/22/2011 11:09

Hello, i like your work very well, but I alsow have a question: Could You please load up your TouchOSC Skin ? Or didn't I found it on Your page ?
Thanks, Alex

Shawn Busker
04/07/2011 16:32

Your processing code is a little off, but I was able to use it for my project. http://pastie.org/1769953 p.s this only took 4 hrs and I'm only 14.

-Cheers, Shawn

05/13/2011 01:29

Wow-these are great! Have you considered selling them? Also, how did you program the arduino without using the usb cable? Keep up the great work - Jon

05/13/2011 01:31

Where can I get one of these - they're so cool!

06/07/2011 09:24

thank you for sharing such a great post its really awesome

07/14/2011 02:13

Nice to be visiting your blog again, it has been months for me. Well this article that I've been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share.

07/19/2011 23:18

Nice post. Please keep continue sharing your great ideas

09/16/2011 03:12


I am trying to build a similar tank, using your code since my programming sucks. I hope you do not mind. Can you please explain me what " inputBuffer[inputLength] != LineEnd " means. I know that you define LineEnd as #. I tried to google #. But, I do not see it. I guess I don't know what # is. Thank you in advance . I am sorry for noob question like this.

10/04/2011 06:16

why the solar panel is under the tank while the sun is above?

11/10/2011 16:18

hello, my father is in a wheelchair and uses a kind of lift to get into his car. Its wired remote control often breaks down, I will try to bring him a smile through his Iphone and your solution Xbee. I hope to be able to apply the method because I am beginner in XBee.
My english is not very good. Sorry.

01/09/2012 12:49


thank you for sharing your code with everybody.
it works really good.

but I would like to be able to control servo motors to, i had found this
tutorial: https://github.com/jaxzin/arduino_touchosc_servo_controller
i tried to embedd this code in yours but i could not make it work.

i also tried firmata to try to use motors and servo's at the same time.

could you please help me out by helping me develop some code ?

David Garcia
03/31/2012 18:24

Hi, I wanted to use the same concept but on an old Big Trak from 1979. Do you have schematics or pictures on how you wired it? I think this is a cool project for me to start with.

Thanks, David G.

05/19/2012 11:31


Can you please let us know how to connect the solar panel? Is the solar panel actually powering the motors? It seems that it wouldn't work. The panel is at the bottom of the tank so it doesn't get sun shine, but even if it did, it wouldn't be powerful enough, right? Or are we missing something? Is it there only to charge batteries? Thank you!

05/30/2012 07:22

Thank you very much for sharing this simple and information post, it is simply written and worth reading this post. i will definitely come back again to read your post. thanks again :)


Your comment will be posted after it is approved.

Leave a Reply