Picture
iPhone Controlled Tank
Picture
iPhone Controlled Tank
Picture
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:
Arduino
Ardumoto
Dual Motor GearBox
Stackable Arduino Headers
Super Awesome Tank Treads
LiPoly Battery Charger
Batteries
Small Solar Panel
XBees
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);
 
  Serial.begin(SerialSpeed);
}
 
// process a command string
void HandleCommand(char* input, int length)
{
  Serial.println(input);
  if (length < 2) { // not a valid command
    return;
  }
  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);
      break;
    case 'RA':
      // motor A reverse
      analogWrite(PwmPinMotorA, value);
      digitalWrite(DirectionPinMotorA, LOW);
      break;
    case 'FB':
      // motor B forwards
      analogWrite(PwmPinMotorB, value);
      digitalWrite(DirectionPinMotorB, LOW);
      break;
    case 'RB':
      // motor B reverse
      analogWrite(PwmPinMotorB, value);
      digitalWrite(DirectionPinMotorB, HIGH);
      break;
    default:
      break;
  } 
}
 
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){
    arduinoPort.write("AF100#");
  }
   if(fader[1] < 0.35){
    arduinoPort.write("AR100#");
  }
  //--------------------------------Motor B
   if(fader[2] > 0.65){
    arduinoPort.write("BF100#");
  }
   if(fader[2] < 0.35){
    arduinoPort.write("BR100#");
  }
  //----------------------------stop commands
     if(fader[1] < 0.65 && fader[1] > 0.35 ){
    arduinoPort.write("AF0#");
  }
       if(fader[2] < 0.65 && fader[2] > 0.35 ){
    arduinoPort.write("BF0#");
  }
 
}

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


Comments

Sat, 28 Nov 2009 9:26:56 pm

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.

Kudos.

 

Thu, 03 Dec 2009 12:45:27 pm

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

++

d

 

Thu, 03 Dec 2009 12:59:15 pm

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

 

Fri, 04 Dec 2009 3:17:23 am

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

Fri, 04 Dec 2009 4:09:14 am

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

Fri, 04 Dec 2009 4:11:55 am

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

 

Fri, 04 Dec 2009 6:23:39 am

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

Fri, 04 Dec 2009 9:05:34 am

 

Fri, 04 Dec 2009 9:11:50 am

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!)

 

Fri, 04 Dec 2009 9:40:43 am

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.

 

John

Fri, 04 Dec 2009 12:51:02 pm

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 ???

 

Fri, 04 Dec 2009 5:15:18 pm

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.

 

Mon, 07 Dec 2009 11:09:58 am

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.

 

Tue, 08 Dec 2009 2:40:00 pm

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?

 

Tue, 08 Dec 2009 2:56:02 pm

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.



 

Cesar

Wed, 09 Dec 2009 11:59:30 am

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

 

Wed, 09 Dec 2009 12:08:59 pm

I used Arduino. www.Arduino.cc

 

John

Fri, 11 Dec 2009 12:17:03 pm

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)?

 

Fri, 11 Dec 2009 12:28:53 pm

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.

 

carlos

Tue, 15 Dec 2009 1:23:55 pm

can I use easyC fro Vex to program the tank

 

Olaf

Wed, 30 Dec 2009 2:38:16 pm

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

 

cESAR

Tue, 19 Jan 2010 12:00:09 pm

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

 

Jonathan

Fri, 29 Jan 2010 12:38:47 pm

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....

 

Sun, 31 Jan 2010 11:44:05 am

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.

 

Cesar

Wed, 17 Feb 2010 1:38:21 pm

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

 

Omega

Thu, 11 Mar 2010 3:26:48 am

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

 

mamo

Mon, 12 Apr 2010 11:29:53 pm

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.

 

Sandro

Thu, 15 Apr 2010 4:57:43 am

hello, your work has been my inspiration

http://www.youtube.com/watch?v=4iGBqb0yiNU

thanks

 

Scott Portocarrero

Sat, 19 Jun 2010 10:49:46 am

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

 

Sun, 11 Jul 2010 5:08:22 pm

pretty much go anywhere a telephone can go.

 

Dom

Sat, 24 Jul 2010 7:49:42 am

How many batteries are you using to power this tank?

 



Leave a Reply