You have to use the Arduino to control the button.
See this page for button control, but use pin 6 instead of 2.
Remember shield pins are connected to Arduino pins (except 2,3 and 7), so you can connect to the shield +GND, 5V and pin 6.
Now you have to merge both examples: sendSMS and button. This sketch should run, please check it:
// libraries
#include <GSM.h>
#define PINNUMBER ""
// initialize the library instance
GSM gsmAccess; // include a 'true' parameter for debug enabled
GSM_SMS sms;
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 6; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup()
{
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
// initialize serial communications
Serial.begin(9600);
Serial.println("SMS Messages Sender");
// connection state
boolean notConnected = true;
// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized");
}
void loop()
{
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
// send the message
sms.beginSMS("+123456789");
sms.print("Hi!");
sms.endSMS();
Serial.println("\nCOMPLETE!\n");
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}