Sim 900 text help

So I have this code, everything works great except that the sim900 board that I have sends a text only after the pir sensor is no longer detecting motion and I would like for it to send the message once the motion is detected.

#include <SoftwareSerial.h>

SoftwareSerial SIM900(7, 8);
int calibrationTime = 15;

//the time when the sensor outputs a low impulse
long unsigned int lowIn;

//the amount of milliseconds the sensor has to be low
//before we assume all motion has stopped
long unsigned int pause = 5000;

boolean lockLow = true;
boolean takeLowTime;

int pirPin = 3; //the digital pin connected to the PIR sensor's output
int relayPin = 8;
int thermPin = 4;

/////////////////////////////
//SETUP
void setup(){
Serial.begin(9600);
pinMode(pirPin, INPUT);
pinMode(relayPin, OUTPUT);
digitalWrite(pirPin, LOW);
pinMode(thermPin, INPUT);
//give the sensor some time to calibrate
Serial.print("calibrating sensor ");
for(int i = 0; i < calibrationTime; i++){
Serial.print(".");
delay(100);
}
Serial.println(" done");
Serial.println("SENSOR ACTIVE");
delay(50);
SIM900.begin(19200);
delay(200);
}
void SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
digitalWrite(9, HIGH);
delay(100);
digitalWrite(9, LOW);
delay(50);
}
void sendSMS()
{
SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message
delay(100);
SIM900.println("AT + CMGS = "+17154416253""); // recipient's mobile number, in international format
delay(100);
SIM900.println("Hello. This is a text message from an Arduino Uno."); // message to send
delay(100);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(100);
SIM900.println();
delay(500);
}

////////////////////////////
//LOOP
void loop(){

if(digitalRead(pirPin) == HIGH && digitalRead(thermPin) == HIGH){
digitalWrite(relayPin, HIGH); //the led visualizes the sensors output pin state

if(lockLow){
//makes sure we wait for a transition to LOW before any further output is made:
lockLow = false;
Serial.println("---");
Serial.print("motion detected at ");
Serial.print(millis()/1000);
Serial.println(" sec");

}
takeLowTime = true;
}

if(digitalRead(pirPin) == LOW){
digitalWrite(relayPin, LOW); //the led visualizes the sensors output pin state
if(digitalRead(thermPin) == LOW){
digitalWrite(relayPin, LOW);
}
if(takeLowTime){
lowIn = millis(); //save the time of the transition from high to LOW
takeLowTime = false; //make sure this is only done at the start of a LOW phase
}
//if the sensor is low for more than the given pause,
//we assume that no more motion is going to happen
if(!lockLow && millis() - lowIn > pause){
//makes sure this block of code is only executed again after
//a new motion sequence has been detected
lockLow = true;
Serial.print("motion ended at "); //output
Serial.print((millis() - pause)/1000);
Serial.println(" sec");

sendSMS();
do {} while (1);
}
}
}

nice try, but code tags have square brackets '[' ']' , not angle brackets '<' '>'.

The only rational explanation for putting the { on the same line as the function/statement is to save real-estate. You shoot that rationalization all to hell when you then put a blank line after the function/statement.

There is NO excuse for jamming the { up against the statement. Thereisarewasonweusewhitespacewhenwriting. Coding is NO different.

There is NO excuse for your code wandering around like a drunken sailor. Use Tools + Auto Format to sober it up.

I would like for it to send the message once the motion is detected.

So, move the call to sendSMS() to where you observe that motion happened.

Why there is a relationship between motion and temperature needs an explanation.

Most of your comments are useless. What any given line of code is doing is obvious. WHY you are doing certain things needs explaining.