iPhone Controlled Robotic Arm Over Wi-Fi

My friend and I were able to send information via the iPhone over wi-fi to the serial port on the Arduino.

Here’s a video:

Ingredients:
Arduino Duemilanove - 0021
Macbook Pro
Internet
3 Futaba S3003 Servos
1 Hi-Tec HS81 Servo
iPhone 4
Metal
Screws
Wiring
Tape
Wood
Darth Vader Action Figure

If anyone’s interested I’ll put the code below. Is there any way you guys can scrutinize our code for us?

Note I’m using Processing to capture the OSC messages from the iPhone via wi-fi because Roctana’s OSCClass for the newest Arduino is not compatible. Processing is doing no image processing - just transferring the data to the Arduino serial port… one byte at a time.

// Arduino Code
// robot arm manipulation
// zak and evan

#include <Servo.h>

Servo shoulder;  
Servo forearm;
Servo elbow;
Servo claw;

int baud = 9600;
int count = 0;
int shoulder_pin = 3;
int forearm_pin = 9;
int elbow_pin = 10;
int claw_pin = 11;

void setup(){
  Serial.begin(baud);
  
  shoulder.attach(shoulder_pin);
  forearm.attach(forearm_pin);
  elbow.attach(elbow_pin);
  claw.attach(claw_pin);
} 
 

void loop(){
  byte inByte;
  
  if(Serial.available()){
     inByte = Serial.read(); // read the byte
 
     if(count == 0){
       forearm.write(inByte);

       count++;
     }else if(count == 1){
       elbow.write(inByte);
       
       count++;
     }else if(count == 2){
       claw.write(inByte);
       
       count++;
     }else if(count == 3){
       shoulder.write(inByte);
       
      count = 0;
    }
  }  
}
// Processing Code
// robot arm manipulation
// zak and evan

import oscP5.*;
import netP5.*;
import processing.serial.*;

Serial port;
OscP5 oscP5;

float shoulder = 0.0f;
float forearm = 0.0f;
float elbow = 0.0f;
float claw = 0.0f;

void oscEvent(OscMessage theOscMessage) {
  String addr = theOscMessage.addrPattern();
  
  if(addr.equals("/1/arm_forearm")){ 
    shoulder = theOscMessage.get(0).floatValue(); 
    forearm = theOscMessage.get(1).floatValue(); 
  }
  if(addr.equals("/1/elbow")){
    elbow = theOscMessage.get(0).floatValue();
  }
  if(addr.equals("/1/claw")){
    claw = theOscMessage.get(0).floatValue();
  }
}

void setup() {
  println("Available serial ports:");
  println(Serial.list());
  
  port = new Serial(this, Serial.list()[0], 9600);

  oscP5 = new OscP5(this,8000);
 }
 
 void draw() {
   println("shoulder:" + shoulder);
   println("forearm:" + forearm);
   println("elbow:" + elbow);
   println("claw:" + claw);
   
   port.write(Math.round(shoulder));
   port.write(Math.round(forearm));
   port.write(Math.round(elbow));
   port.write(Math.round(claw));
 }