Ultrasonic sensor + a6 gsm

Hello,

I have a school project using the ultrasonic HC SR04, A6 gsm module + arduino nanno, to call my mobile when the distance measured by the sensor is interrupted

Having trouble with the code for the calling the mobile part, serial monitor appears to go through all the motions ok, but I’m not receiving the call

Any help will be greatly appreciated, thanks

#include<SoftwareSerial.h>

#define trigPin 9

#define echoPin 10

#define piezoPin 8

SoftwareSerial mySerial(2, 3);

int normalDistance;

boolean triggered = false;

long duration, distance;

void setup()

{

mySerial.begin(9600);

Serial.begin (9600);

delay(100);

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode(piezoPin, OUTPUT);

digitalWrite(piezoPin, HIGH);

long duration, distance;

while (millis() < 5000)

{

digitalWrite(piezoPin, HIGH);

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance= duration*0.034/2;

normalDistance = distance;

Serial.print("Distance: ");

Serial.println(distance);

digitalWrite(piezoPin, LOW);

} }

void loop()

{

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance= duration*0.034/2;

Serial.print("Distance: ");

Serial.println(distance);

if (distance < normalDistance-50)

{

triggered = true;

}

else

{

triggered = false;

}

if (triggered)

{

tone(piezoPin, 635);

delay(500);

tone(piezoPin, 912);

delay(250);

  
 
 char phone_no[]="07510XXXXXX";
 
void setup()
{
Serial.begin(9600);  
delay(400);
Serial.println("AT");
delay(1000);
Serial.print("ATD");
Serial.println(phone_no);
//Serial.println(";");
delay(8000);
Serial.println("ATH");


}

void loop()
{
}