gps and gsm and Microswitch

hi
how can we send gps data with gsm when we click on a Microswitch using arduino …

gps and gsm code :

#include <SoftwareSerial.h>

SoftwareSerial gpsSerial(10, 11); // RX, TX (TX not used)
const int sentenceSize = 80;

char sentence[sentenceSize];

void setup()
{
 Serial.begin(9600);
 gpsSerial.begin(9600);
}

void loop()
{
 static int i = 0;
 if (gpsSerial.available())
 {
   char ch = gpsSerial.read();
   if (ch != '\n' && i < sentenceSize)
   {
     sentence[i] = ch;
     i++;
   }
   else
   {
     sentence[i] = '\0';
     i = 0;
     displayGPS();
   }
 }
}

void displayGPS()
{
 char field[20];
 getField(field, 0);
 if (strcmp(field, "$GPRMC") == 0)
 {
   // Set up the SMS
   Serial.println("AT");
   delay(1000);
   Serial.println("AT+CMGF=1");
   delay(1000);
   Serial.println("AT+CMGS=\"09356256637\""); //CHANGE TO DESTINATION NUMBER
   delay(1000);

   // Send the GPS data
   Serial.print("Lat: ");
   getField(field, 3);  // number
   Serial.print(field);
   getField(field, 4); // N/S
   Serial.print(field);

   Serial.print(" Long: ");
   getField(field, 5);  // number
   Serial.print(field);
   getField(field, 6);  // E/W
   Serial.println(field);
Serial.print(" Im not very well !!!! ");
   // End the SMS
   Serial.write(26);
   delay(10000);
 }
}

void getField(char* buffer, int index)
{
 int sentencePos = 0;
 int fieldPos = 0;
 int commaCount = 0;
 while (sentencePos < sentenceSize)
 {
   if (sentence[sentencePos] == ',')
   {
     commaCount ++;
     sentencePos ++;
   }
   if (commaCount == index)
   {
     buffer[fieldPos] = sentence[sentencePos];
     fieldPos ++;
   }
   sentencePos ++;
 }
 buffer[fieldPos] = '\0';
}

how can we send data when we click on a Microswitch
how can we chenge this code
please send me its codes
please …
please …

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

See how the text of your code turns into italics partway through? That is caused by the forum software misinterpreting your code as markup. Please read the instructions thread ('How to use this forum') and put your code in tags, or nobody will be able to read it as you intended it.

Is this microswitch a normal push button, just does on/off?

In your code, I cant see any where that you are referring this switch.

Since you are using the Serial port for I/O to the SIM900A you will have trouble reading any error codes sent by the SIM900A. Try using SoftwareSerial to talk to the SIM900A and use Serial for debugging. You should probably not ignore replies sent by the SIM900A since they are probably telling you why the message is not being sent.

Here is an example that returns the result of an AT command sent to a serial device:

#include <SoftwareSerial.h>
SoftwareSerial monitor(2, 3); //rx tx

void setup() {
  Serial.begin(9600);
  monitor.begin(9600);
}

String command(const char *toSend, unsigned long milliseconds) {
  String result;
  Serial.print("Sending: ");
  Serial.println(toSend);
  monitor.println(toSend);
  unsigned long startTime = millis();
  unsigned long lastCharTime = startTime;
  Serial.print("Received: ");
  while (millis() - startTime < milliseconds) {
    if (monitor.available()) {
      char c = monitor.read();
      lastCharTime = millis();
      Serial.write(c);
      result += c;  // append to the result string
    }
  }  // End timeout
  Serial.println();
  Serial.print(F("Received in "));
  Serial.print(lastReceivedTime - startTime);
  Serial.println(F(" milliseconds."));
  return result;
}

You have two sketches, a gps sketch and a gsm sketch. You want to combine these two sketches so that, on a button press, you cant send GPS coordinates via GSM. It is all very urgent. Have a look here: https://www.google.ch/?gws_rd=ssl#q=site:+arduino.cc+combine+sketches