Using a Ultrasonic range sensor to Compute distance and send message

Hello everyone I am trying to get my arduino uno to send me data from my ultrasonic range finder. I have a program right now that is allowing me to send it a message and then it does the ping but I am having trouble getting it to reply with the distance. I have another program that will let send me a message when it gets to a certain distance ( ==40) but I want it to send me all distances when I text it a code. Any help would be greatly appreciated and I am also very new to the arduino world. I am using and arduino uno and a sim 900 with a 4 pin ultrasonic range finder.
Thanks!

#include <GPRS_Shield_Arduino.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#include <NewPing.h>

#define ledPin 13
#define TRIGGER_PIN 12 // Trigger Pin of sensor
#define ECHO_PIN 11 // Echo pin of sensor
#define MAX_DISTANCE 300 // Maximum distance we want to ping.
char inchar; // Will hold the incoming character from the GSM shield
SoftwareSerial SIM900(7, 8);

int led1 = 10;
int led2 = 11;
int led3 = 12;
int led4 = 13;

#define PIN_TX 7
#define PIN_RX 8
#define BAUDRATE 9600
#define PHONE_NUMBER "0000000000"
#define MESSAGE "X"

GPRS gprsTest(PIN_TX,PIN_RX,BAUDRATE);//RX,TX,Baud

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

void setup()
{
Serial.begin(19200);
// set up the digital pins to control
pinMode(ledPin, OUTPUT);
Serial.begin(9600); // Open serial monitor

// wake up the GSM shield
SIM900power();
SIM900.begin(19200);
delay(20000); // give time to log on to network.
SIM900.print("AT+CMGF=1\r"); // set SMS mode to text
delay(100);
SIM900.print("AT+CNMI=2,2,0,0,0\r");
// blurt out contents of new SMS upon receipt to the GSM shield's serial out
delay(100);
Serial.println("Ready...");
}

void SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(7000);
}

void loop()
{
//If a character comes in from the cellular module...
if(SIM900.available() >0)
{
inchar=SIM900.read();
if (inchar=='#')
{
delay(10);

inchar=SIM900.read();
if (inchar=='a')
{
delay(10);
inchar=SIM900.read();
if (inchar=='0')
{
delay(50); // Wait 50ms between pings.
unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).
Serial.print("Ping: ");
Serial.print(uS / US_ROUNDTRIP_CM); // Convert ping time to distance in cm and print result (0 = outside set distance range)
Serial.println("cm");
int X = uS / US_ROUNDTRIP_CM;

digitalWrite(ledPin,HIGH);
Serial.println("start to send message ...");
gprsTest.sendSMS(PHONE_NUMBER,MESSAGE); //define phone number and text
delay(1000);
}
{
SIM900.println("AT+CMGD=1,4"); // delete all SMS
}
}
}
}
}

Hi Swann1993,
I know nothing of GPS and andriod apps, etc. But I just can't see where the U/S functions are? in your code. I have used various U/S sensors and my code works OK, never fails, NO special library! it's just not needed.

Also why have you defined echo and trigger on pins 11-12, but also done int led2 = 11;int led3 = 12; I've seen people defne a max distance before, never understand why!!

Here's my code for the U/S:

long scanner(long cm)
{
	const int pingPin=2, EchoPin=3;
	long duration;

	// The SRF005 is triggered by a HIGH pulse of 2 or more microseconds.
	// Give a short LOW pulse before to ensure a clean HIGH pulse:
	pinMode(pingPin, OUTPUT);
	pinMode(EchoPin, INPUT);  

	digitalWrite(pingPin, LOW);
	delayMicroseconds(2);
	digitalWrite(pingPin, HIGH);
	delayMicroseconds(2);
	digitalWrite(pingPin, LOW); 
	duration = pulseIn(EchoPin, HIGH);
	delay(100);

	// convert the time into a distance
	// inches = microsecondsToInches(duration);
	cm = microsecondsToCentimeters(duration);
	return (cm);
}
//------------------------------------------------------------------
long microsecondsToCentimeters(long microseconds)
{
	// The speed of sound is 340 m/s or 29 microseconds per centimetre.
	// The ping travels out and back, so to find the distance of the
	// object we take half of the distance travelled.
	return microseconds / 29 / 2;
}

Hope it might help, regards.

Mel.

Why you're using wire.h in your sketch?