Bluetooth shield

Here is an example that I wrote to get data from Bluetooth to control a servo.
You send a packet with the syntax as < delayTime, servoPosition >. The sketch parses the packet and moves the servo from 90 degrees to the position in servoPosition then the servo pauses at that position for delayTime and returns to 90 degrees. Maybe you can adapt this to your needs. Note that my Bluetooth module is connected to Arduino pin 4 (RX to BT TX) and pin 7 (TX to BT RX) using software serial so I can use the hardware serial for upload and displaying the data received. Thanks again to Robin2 for the serial input basics thread.

So send, from the laptop, "<3000,170>" (without quotes) and the servo should move from 90 degrees to 170 degrees and pause for 3000 milliseconds then return to 90 degrees.

#include <Servo.h>
#include <SoftwareSerial.h>

Servo servo;
SoftwareSerial bt(4, 7); // RX, TX

const byte numChars = 12;
char receivedChars[numChars];
char tempChars[numChars];        // temporary array for use when parsing

// variables to hold the parsed data
unsigned long delayTime;  // servo sweep delay time
int servoPosition = 0;    // servo position

boolean newData = false;

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  bt.begin(9600);
  servo.write(90);
  servo.attach(2);
}

void loop()
{ // run over and over
  recvWithStartEndMarkers();
  if (newData == true)
  {
    strcpy(tempChars, receivedChars);
    // this temporary copy is necessary to protect the original data
    //   because strtok() used in parseData() replaces the commas with \0
    parseData();
    showParsedData();
    newData = false;

    servo.write(servoPosition);
    delay(delayTime);
    servo.write(90);    
  }
}

void recvWithStartEndMarkers() {
  static boolean recvInProgress = false;
  static byte ndx = 0;
  char startMarker = '<';
  char endMarker = '>';
  char rc;

  while (bt.available() > 0 && newData == false)
  {
    rc = bt.read();

    if (recvInProgress == true)
    {
      if (rc != endMarker)
      {
        receivedChars[ndx] = rc;
        ndx++;
        if (ndx >= numChars) {
          ndx = numChars - 1;
        }
      }
      else
      {
        receivedChars[ndx] = '\0'; // terminate the string
        recvInProgress = false;
        ndx = 0;
        newData = true;
      }
    }

    else if (rc == startMarker) 
    {
      recvInProgress = true;
    }
  }
}

//============

void parseData()
{ // split the data into its parts

  char * strtokIndx; // this is used by strtok() as an index

  strtokIndx = strtok(tempChars, ",");     // get the first part - the delay
  delayTime = atol(strtokIndx);

  strtokIndx = strtok(NULL, ","); // this continues where the previous call left off
  servoPosition = atoi(strtokIndx);
}

//============

void showParsedData()
{
  Serial.print("delay time ");
  Serial.println(delayTime);
  Serial.print("servo position ");
  Serial.println(servoPosition);
}