sms triggering

I want to have an sms sent when the if statement is triggered by the distance, can anyone help me with the coding to have the sms triggered under loop.

const int TriggerPin = 2;
const int  EchoPin = 4;
const int analogInputPin = 4; 
#include <SPI.h>
#include <Andee.h>
AndeeHelper analogDisplay;
AndeeHelper sensor1; 
AndeeHelper sendMessage;
AndeeHelper SMSobject; 
AndeeHelper displaybox;
AndeeHelper button; 
AndeeHelper speechObject; 


char messageRecipent [] = "+1234567890";
char message [] = "Ready to assist you today"; 
void setup() {

Serial.begin(9600);
Andee.begin();
Andee.clear();
setInitialData();
}
void setInitialData()
{
sendMessage.setId(0);      
sendMessage.setType(BUTTON_IN);
sendMessage.setLocation(0,0,FULL);
sendMessage.setTitle("Send SMS");

SMSobject.setId(1);     
SMSobject.setType(SMS_SENDER);
SMSobject.setRecipient("+8564004967");
SMSobject.setMessage("ALERT ALERT ALERT... OBSTACLE DETECTED AHEAD");

displaybox.setId(0);   //text to speech
displaybox.setType(DATA_OUT);
displaybox.setTitle("Text to Speech");
displaybox.setData("Be sure to unmute your phone to hear your phone talk!"); 
button.setId(1); 
button.setType(BUTTON_IN);
button.setLocation(1,0,FULL);
button.setTitle("Say something!");
button.setColor(THEME_RED_DARK);

sensor1.setId(0);
sensor1.setType(DATA_OUT);
sensor1.setLocation(0, 0, FULL);
sensor1.setTitle("Ultrasonic Sensor");
sensor1.setData("Data For Sensor");
sensor1.setUnit("Unit Field for Data");

analogDisplay.setId(0);  
analogDisplay.setType(DATA_OUT);
analogDisplay.setLocation(0, 0, FULL);
analogDisplay.setTitle("Ultrasonic Sensor information");
analogDisplay.setData(""); 
}
void loop() {

long duration, inches, cm;


pinMode(TriggerPin, OUTPUT);
digitalWrite(TriggerPin, LOW); 
delayMicroseconds(2); 
digitalWrite(TriggerPin, HIGH); 
delayMicroseconds(10);
digitalWrite(TriggerPin, LOW); 


pinMode(EchoPin, INPUT); duration = pulseIn(EchoPin, HIGH); 

inches = microsecondsToInches(duration); 
cm = microsecondsToInches(duration);

Serial.print(inches);
Serial.print(" INCHES AWAY");
Serial.println();

delay(100);

sensor1.update();
int reading = analogRead(analogInputPin);
analogDisplay.setData(reading);
analogDisplay.update();

float distance;
distance = inches;


if(distance <= 12){
Serial.print("Object Detected = ");
speechObject.updateData("Confucius say: Man run in front of car get tired,")
}
}


long microsecondsToInches(long microseconds) {

return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds) {

return microseconds / 29 / 2; 

delay(2000);

}

You have posted code without using code tags. This creates certain problems and obstacles for other forum members. The code tags make the code look

like this

when posting source code files. It makes it easier to read, and can be copied with a single mouse click.
If you have already posted without using code tags, open your message and select "modify" from the pull down menu labelled, "More", at the lower left corner of the message. Highlight your code by selecting it (it turns blue), and then click on the "</>" icon at the upper left hand corner. Click on the "Save" button. Code tags can also be inserted manually in the forum text using the [code] and [/code] metatags.

When you are finished that, please read these two posts:

How to use this forum - please read.
and
Read this before posting a programming question ...

Can you look at it now??????

cpatriot12:
Can you look at it now??????

Thanks for adding code tags. What's wrong with it? Oh, I see... there is no SMS code in there at all. I assume you have some kind of GPRS shield? Have you researched GPRS libraries?

Also, is this a sneaky attempt to restart the Annikken Andee thread on exactly the same subject?

No it is not... anyway

The if statement in the loop would look like:

 if(f<=300){
  speechObject.updateData("ALERT ALERT ALERT...,"); 
  speechObject.updateData("Obstacle Detected Ahead"); 
  SMSobject.send();
  delay(500);

but the sms wouldn't send. In the library below, the text is sent when presses on Annikken Andee and only then but when I try to send it by triggering the if statement, it wont work.

// Always include these libraries. Annikken Andee needs them
// to work with the Arduino!
#include <SPI.h>
#include <Andee.h>

// We'll use a button to send the message
AndeeHelper sendMessage;
AndeeHelper SMSobject; // The message and recipient must be declared as an object

// You can use the text input button to get the user to set the
// recipient number and even the message itself!
char messageRecipient[] = "+7329103772";
char message[] = "Hello World!";

// The setup() function is meant to tell Arduino what to do 
// only when it starts up.
void setup()
{
  Andee.begin();  // Setup communication between Annikken Andee and Arduino
  Andee.clear();  // Clear the screen of any previous displays
  setInitialData(); // Define object types and their appearance
}

// This is the function meant to define the types and the apperance of
// all the objects on your smartphone
void setInitialData()
{
  sendMessage.setId(0);
  sendMessage.setType(BUTTON_IN);
  sendMessage.setLocation(0,0,FULL);
  sendMessage.setTitle("Send SMS");
  
  SMSobject.setId(1);
  SMSobject.setType(SMS_SENDER); // Sets object as an SMS object
  SMSobject.setRecipient(messageRecipient);
  SMSobject.setMessage(message);
}

// Arduino will run instructions here repeatedly until you power it off.
void loop()
{
  if( sendMessage.isPressed() ) // When user presses the send button on phone
  {
    sendMessage.ack(); // Acknowledge button press
    SMSobject.send(); // Sends the SMS to the recipient
  }

  sendMessage.update();
  // Do not update SMS objects!
  
  delay(500); // Always leave a short delay for Bluetooth communication
}

You were told in the previous thread that we can't have any idea what is in the Andee library. Go and ask the people who would know, or "use the force, Luke".