Command for Ultrasonic sensor with arduino nano and xbee freaduino pro sensor

hye guys..

now im currently running on project ultrasonic problem now is, i want to transmit data to the my android via bluetooth which is im using xbee freaduino pro sensor shield and xbee bluetooth bee B2.0..for the first try setup, the bluetooth is working..i set the bluetooth to read what i sent from android, and it will write back what i have sent to it..but now, i want to command such as, when im sending command 'r', it will revert back to me the data about centimeter,meters, and volume..but, its revert to me the word 'r'..which is like the first my arduino code...

#define echoPin 13
#define trigPin 12

char r;//for xbee
char message; //for xbee
int flag = 0;

void setup() {
  float j = 1.102;
  // initialize serial communication:
  Serial.println("OK then, you first, say something.....");  //for xbee
  Serial.println("Hit r for result,"); //for xbee

  Serial.println(""); //for xbee

void loop()
  float j = 1.102;  //volume constant
  float v;
  float cm;

  digitalWrite(2, HIGH);
  // establish variables for duration of the ping,
  // and the distance result in inches and centimeters:
  long  duration;
  long getDecimal (float m);

  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
  pinMode(12, OUTPUT);//attach pin 12 to trig
  digitalWrite(12, LOW);
  digitalWrite(12, HIGH);
  digitalWrite(12, LOW);

  // The same pin is used to read the signal from the PING))): a HIGH
  // pulse whose duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  pinMode(13, INPUT);//attach pin 13 to echo
  duration = pulseIn(13, HIGH);
  cm = microsecondsToCentimeters(duration);

  // convert the time into a distance
  float met = cm * 0.01;//change cm to m(1m = 100cm)
  v = (3.142*j*j*met);//calculate volume

  // check if data has been sent from the computer:
  if (Serial.available()) { //for xbee
    /* read the most recent byte */
    message =; //for xbee
    flag = 0;
    if (message == 'r');//for xbee
    Serial.println(" cm ");

    Serial.println(" m");

    Serial.print (v);
    Serial.println("  Volume(m^3)");
    flag = 1;
    /*ECHO the value that was read, back to the serial port. */


long microsecondsToCentimeters(long microseconds)
  // According to Parallax's datasheet for the PING))), there are
  // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
  // second).  This gives the distance travelled by the ping, outbound
  // and return, so we divide by 2 to get the distance of the obstacle.
  // See:
  return microseconds / 29 / 2;

someone please help me..thank you