Manipular SMS

Boa Noite!

Estou realizando um projeto onde uso o arduino duemilanove e o shield sim900d.A minha intençao é receber um sms pelo arduino, após ele receber acionar um led e enviar um sms ao número que chamou com a informação de que o led foi aceso.

Eu já consegui recber o sms, mas não sei acrescentar no código a informação para ele acionar o led e enviar o sms de volta.

Se alguém puder me ajudar vou ficar muito agradecido. Abaixo o código que estou usando:

#include <GSM.h>

// PIN Number for the SIM
#define PINNUMBER ""

// initialize the library instances
GSM gsmAccess;
GSM_SMS sms;

// Array to hold the number a SMS is retreived from
char senderNumber[20];
int powerkey = 5;
int statuspin = 6;
int pinState = 0;
String inputString = ""; // a string to hold incoming data
boolean stringComplete = false; // whether the string is complete
char inChar;

void setup()
{
// initialize serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
pinMode(powerkey, OUTPUT);
pinMode(statuspin, INPUT);
inputString.reserve(200);
} delay(100);

Serial.println("Serial conectada");

// connection state
boolean notConnected = true;

// Start GSM connection
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
else
{
Serial.println("Nao conectado");
delay(1000);
}
}

Serial.println("GSM inicializado");
Serial.println("Aguardando novas mensagens");
}

void loop()
{
char c;

// If there are any SMSs available()
if (sms.available())
{
Serial.println("Mensagem recebida de:");

// Get remote number
sms.remoteNumber(senderNumber, 20);
Serial.println(senderNumber);

// An example of message disposal
// Any messages starting with # should be discarded
if(sms.peek()=='#')
{
Serial.println("SMS Descartada");
sms.flush();
}

// Read message bytes and print them
while(c=sms.read())
Serial.print(c);

Serial.println("\nFim da Mensagem");

// Delete message from modem memory
sms.flush();
Serial.println("MENSAGEM APAGADA");
}

delay(1000);

}

Abraços

Alencar

// Read message bytes and print them
while(c=sms.read())
Serial.print(c);

Podes fazer aqui carregando a mensagem para dentro de um char array e depois usas um strcmp() para comparar a mensagem com algo que queiras.Se coincidir (nao existe diferença na string) executas uma funçao.
Algo assim:

    // Read message bytes and print them
    unsigned int i = 0
    unsigned char mySmsText[150];//O maximo do conteudo de uma sms penso que sao 150 caracteres.Dificilmente iras usar os 150 caracteres mas ...
    while(c=sms.read()){
      mySmsText[i++] = c;
      mySmsText[i]= '\0';
    }
      
     if(strcmp(mySmsText, "LigaLed") == 0){
     Serial.print("Vou ligar o led");
     digitalWrite(a tua saida,1);
     }
     
    Serial.println("\nFim da Mensagem");
   
    // Delete message from modem memory
    sms.flush();
    Serial.println("MENSAGEM APAGADA");

Nao testei mas deve ser algo do genero ...