GPS+GSM shield

Hello guys, I’m here again. Another newbie question.

Additional feature of our project is the GPS.

This is the sample code for the GSM to send SMS;

char Rx_data[50];
unsigned char Rx_index = 0;
int i = 0;
char msg[160];
int sig;

void setup() {
  Serial.begin(38400);
  
  initGSM();
  send_msg("09166120858", "Hello");
}

void loop() {
  //none
}

void send_msg(char *number, char *msg)
{
  char at_cmgs_cmd[30] = {'\0'};
  char msg1[160] = {'\0'};
  char ctl_z = 0x1A;

  sprintf(msg1, "%s%c", msg, ctl_z);
  sprintf(at_cmgs_cmd, "AT+CMGS=\"%s\"\r\n",number);
  
  sendGSM(at_cmgs_cmd);
  delay(100);
  delay(100);
  delay(100);
  sendGSM(msg1);
  delay(100);
}

void sendGSM(char *string){
  Serial.write(string);
  delay(90);
}

void clearString(char *strArray) {
  int j;
  for (j = 100; j > 0; j--)
    strArray[j] = 0x00;
}

void send_cmd(char *at_cmd, char clr){
  char *stat = '\0';
  while(!stat){
    sendGSM(at_cmd);
    delay(90);
    readSerialString(Rx_data);
    
    stat = strstr(Rx_data, "OK");
  }
  if (clr){
    clearString(Rx_data);
    delay(200);
    stat = '\0';
  }
}

void initGSM(){
  
  send_cmd("AT\r\n",1);						
//  send_cmd("ATE0\r\n",1); // Turn off automatic echo of the GSM Module	
	
  send_cmd("AT+CMGF=1\r\n",1);			// Set message format to text mode
  //Sucess
  
  Serial.println("Success");
	
  delay(1000);
  delay(1000);
  delay(1000);
}

void readSerialString (char *strArray) {
  
  if(!Serial.available()) {
    return;
  }
  
  while(Serial.available()) {
    strArray[i] = Serial.read();
    i++;
  }
}

And the code for GPS. The info that I need is only the Latitude and Longtitude.

#include <SoftwareSerial.h>
SoftwareSerial mySerial(7,8);
#include <TinyGPS.h>

long lat,lon;
TinyGPS gps;

void setup()
{
  Serial.begin(19200);
  mySerial.begin(9600);
}

void loop()
{
  while(mySerial.available())
  {
    if(gps.encode(mySerial.read()))
    {
      gps.get_position(&lat,&lon);
      
      Serial.print("Position: ");
      Serial.print("lat: ");Serial.print(lat);Serial.print(" ");
      Serial.print("lon: ");Serial.println(lon);Serial.print(" ");
    }
  }
}

How will I send the info from GPS? What am I gonna do to this part → send_msg(“09166120858”, “Hello”);
What will I change to “Hello” in order to send the data from GPS. Please help me.

UP

what exactly are you trying to do ?

are you trying to send the GPS coordinates via SMS ?

look at the code in the GPS section that displays the coordinates, and then put that into the code in the SMS section that does the sending.

people need to NOT play with shields until they are confident with all the basics. i see another thread with displaying LED state to an LCD !!

use the Serial Monitor to learn the basics - THEN start getting fancy.

/rant (just call it envy that ppl have money to spend on these fantastic shields and not the patience to go through the basics FIRST)

I'm sorry. But I don't know how to put it instead of "Hello". So please help me.

xeanne928: I'm sorry. But I don't know how to put it instead of "Hello". So please help me.

okay then, the basics first; how much of this page are you confident with; http://arduino.cc/en/Reference/HomePage

do you know how [color=orange][b]Serial.print[/b][/color] works ? do you know how to use functions and variables ?