Problem to call SMS Function

Hi to all.

I'm trying to write a program that when I close a contact on the board, it uses the GSM Shield to send multiple SMS. I wrote a function than sends one at time the messages like this:

digitalWrite(ledPin2, HIGH);
  sms.beginSMS(numero1);
  sms.print(txtMsg);
  sms.endSMS();
  delay(1500);
  sms.beginSMS(numero2);
  sms.print(txtMsg);
  sms.endSMS();
  delay(1500);

I know that it isn't the best mode to write code... So I'm trying to write it with an array and a for cycle.

#include <GSM.h>
#include <avr/wdt.h>

#define PINNUMBER "1234"
#define pulsante 8
unsigned long inizio = 0;
int controllo = 0;
unsigned long tempo = 3000L;
const int  ledPin1 = 10;
const int  ledPin2 = 11;
boolean stato;

char destinatari[23][11] = {"number1",..."number23"};

char txtMsg[90]= "Message Text"

GSM gsmAccess;
GSM_SMS sms;

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

  wdt_enable(WDTO_8S);
  
  pinMode (pulsante, INPUT);
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  digitalWrite(ledPin1, LOW);
  digitalWrite(ledPin2, LOW);

  Serial.println("SMS Sender");

  boolean notConnected = true;
  
  while(notConnected)
  {
    if(gsmAccess.begin(PINNUMBER)==GSM_READY){
      notConnected = false;
      digitalWrite(ledPin1, HIGH);
      }
    else
    {
      Serial.println("Not Connected");
      delay(1000);
    }
  }
  Serial.println("GSM initialized");
}

void loop() {
  if (digitalRead(pulsante)==HIGH && controllo == 0){
    Serial.println("CONTACT CLOSED - Wait 3 seconds...");
    inizio = millis();
    wdt_reset();
    while(digitalRead(pulsante)==HIGH) {
      if ((millis()-inizio)>=tempo){
        controllo = 1;
        break;
      }
    }
    if(controllo == 1) {
      Serial.println("CONTACT CLOSED - Sending SMS...");
      wdt_reset();
      
      for (int i=0; i < 23; i++)
      {
        stato = false;
        for (int tries=0; tries < 3  && stato == false; tries++)
        {
        stato = sendSMS(destinatari[i]);
        }
        if (stato == false)  Serial.println("Error sending SMS");
      }


    }
  }
  if (digitalRead(pulsante)==LOW){
    Serial.println("STANDBY - Waiting...");
    wdt_reset();
    controllo = 0;
  }
}

boolean sendSMS(char numero){
  boolean invio;
  digitalWrite(ledPin2, HIGH);
  sms.beginSMS(numero);
  sms.print(txtMsg);
  invio = sms.endSMS();
  digitalWrite(ledPin2, LOW);
  return invio;
}

What's wrong, I don't understand.

Thank in advice, Marco.

What's wrong, I don't understand.

The code does something. You did not say what it does.
The code produces some serial output. You did not share that.

I don't understand how you can expect help, given so little information.

The program monitor the state ofa the pin 8 of Arduino. When this pin goes to state HIGH for more of 3 seconds the sketch goes into the for cycle. Then he try to send the SMS three times for each number stored in the array "destinatari" calling the function "sendSMS".

Here the error messages from the compiler:

Arduino:1.6.7 (Windows 7), Scheda:"Arduino/Genuino Uno"

In file included from C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM.h:46:0,

                 from C:\Users\Marco\Documents\Arduino\sketch_may16d\sketch_may16d.ino:1:

C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3ShieldV1BandManagement.h:49:125: warning: 'typedef' was ignored in this declaration [enabled by default]

 typedef enum GSM3GSMBand {UNDEFINED, EGSM_MODE, DCS_MODE, PCS_MODE, EGSM_DCS_MODE, GSM850_PCS_MODE, GSM850_EGSM_DCS_PCS_MODE};

                                                                                                                             ^

C:\Users\Marco\Documents\Arduino\sketch_may16d\sketch_may16d.ino: In function 'void setup()':

C:\Users\Marco\Documents\Arduino\sketch_may16d\sketch_may16d.ino:38:33: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     if(gsmAccess.begin(PINNUMBER)==GSM_READY){

                                 ^

C:\Users\Marco\Documents\Arduino\sketch_may16d\sketch_may16d.ino: In function 'void loop()':

sketch_may16d:71: error: invalid conversion from 'char*' to 'char' [-fpermissive]

         stato = sendSMS(destinatari[i]);

                                      ^

sketch_may16d:86: error: initializing argument 1 of 'boolean sendSMS(char)' [-fpermissive]

 boolean sendSMS(char numero){

         ^

C:\Users\Marco\Documents\Arduino\sketch_may16d\sketch_may16d.ino: In function 'boolean sendSMS(char)':

sketch_may16d:89: error: invalid conversion from 'char' to 'const char*' [-fpermissive]

   sms.beginSMS(numero);

                      ^

In file included from C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM.h:53:0,

                 from C:\Users\Marco\Documents\Arduino\sketch_may16d\sketch_may16d.ino:1:

C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3SMSService.h:69:7: error:   initializing argument 1 of 'int GSM3SMSService::beginSMS(const char*)' [-fpermissive]

   int beginSMS(const char* to);

       ^

exit status 1
invalid conversion from 'char*' to 'char' [-fpermissive]

  Questo report potrebbe essere più ricco di informazioni con
  "Mostra un output dettagliato durante la compilazione"
  abilitato in "File > Impostazioni"

P.S. Sorry for my bad explanation but it's not easy for me to write in a foreign language.

Marco

Then he try to send the SMS three times for each number stored in the array "destinatari" calling the function "sendSMS".

The code can't possibly try to send the SMS three times for each number if it can't even be compiled. Don't post "why doesn't this work" when you mean "why doesn't this compile". You waste everybody's time when you do that.

sketch_may16d:71: error: invalid conversion from 'char*' to 'char' [-fpermissive]

stato = sendSMS(destinatari*);[/quote]*
Interesting error message, since it appears that destinatari is a 2D array, and that destinatari[ i ] is a string. But, when I try to compile your code,
* *char destinatari[23][11] = {"number1",..."number23"};* *
hasn't a hope in hell of compiling.
If you post some code that has a hope in hell of compiling, we might be able to help. Until then, good luck.

Thank you for your time wasted with me. I will not ask anything anymore..

Marco

boolean sendSMS(char numero){

You probably meant:

boolean sendSMS(char *numero){

You might need to make it:

boolean sendSMS(const char *numero){

Thank you John for your help. I Will try like this and i let you know if it works!

Thank you again, Marco.

Now it works! Thank you very much johnwasser!

Marco