user42833: I am working on a module to send messages. I write the message on the serial monitor + phone number and I have to send the message to the line.
Question:
How to send messages through the SIM900A shield?
Problem:
What am I doing wrong in my code? Because I do not get an error but it does not send the SMS using the shield.
Try:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(6, 7);
char msg;

void setup() {
  mySerial.begin(9600); // Setting the baud rate of GSM Module  
  Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
  delay(100);
}

void loop() {
  if (Serial.available()>0)
    switch(Serial.read()) {
      mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
      delay(1000); // Delay of 1000 milli seconds or 1 second
      mySerial.println("AT+CMGS=\"+XXXXXXXXX\"\r"); // mobile number
      delay(1000);
      mySerial.println("sim900a sms");// The SMS text you want to send
      delay(100);
      mySerial.println((char)26);// ASCII code of CTRL+Z
      delay(1000);
    }
  if (mySerial.available()>0) Serial.write(mySerial.read());
}

This is my shield

Other try:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(6, 7);
char msg;

void setup() {
  mySerial.begin(9600);  // Setting the baud rate of GSM Module  
  Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
  delay(100);
}

void loop() {
  mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
  delay(1000);  // Delay of 1000 milli seconds or 1 second
  mySerial.println("AT+CMGS=\"+XXXXXXXXX\"\r"); // mobile number
  delay(1000);
  mySerial.println("sim900a sms");// The SMS text you want to send
  delay(100);
  mySerial.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
}


user41696: There was not really a question, but I do notice there is no case's in your switch statement..
example from here
// do something different depending on the range value:
  switch (range) {
    case 0:    // your hand is on the sensor
      Serial.println("dark");
      break;
    case 1:    // your hand is close to the sensor
      Serial.println("dim");
      break;
    case 2:    // your hand is a few inches from the sensor
      Serial.println("medium");
      break;
    case 3:    // your hand is nowhere near the sensor
      Serial.println("bright");
      break;
  }
  delay(1);        // delay in between reads for stability


42833: <p>I am working on a module to send messages. I write the message on the serial monitor + phone number and I have to send the message to the line.</p>

<p><strong><em>Question:</em></strong></p>

<p>How to send messages through the SIM900A shield?</p>

<p><strong><em>Problem:</em></strong>
What am I doing wrong in my code? Because I do not get an error but it does not send the SMS using the shield.</p>

<p>Try:</p>

<pre><code>#include &lt;SoftwareSerial.h&gt;
SoftwareSerial mySerial(6, 7);
char msg;

void setup() {
  mySerial.begin(9600); // Setting the baud rate of GSM Module  
  Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
  delay(100);
}

void loop() {
  if (Serial.available()&gt;0)
    switch(Serial.read()) {
      mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
      delay(1000); // Delay of 1000 milli seconds or 1 second
      mySerial.println("AT+CMGS=\"+XXXXXXXXX\"\r"); // mobile number
      delay(1000);
      mySerial.println("sim900a sms");// The SMS text you want to send
      delay(100);
      mySerial.println((char)26);// ASCII code of CTRL+Z
      delay(1000);
    }
  if (mySerial.available()&gt;0) Serial.write(mySerial.read());
}
</code></pre>

<p><strong><em>This is my shield</em></strong>
<a href="https://i.stack.imgur.com/soDIG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/soDIG.jpg" alt="This is my shield"></a></p>

<p>Other try:</p>

<pre><code>#include &lt;SoftwareSerial.h&gt;
SoftwareSerial mySerial(6, 7);
char msg;

void setup() {
  mySerial.begin(9600);  // Setting the baud rate of GSM Module  
  Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
  delay(100);
}

void loop() {
  mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
  delay(1000);  // Delay of 1000 milli seconds or 1 second
  mySerial.println("AT+CMGS=\"+XXXXXXXXX\"\r"); // mobile number
  delay(1000);
  mySerial.println("sim900a sms");// The SMS text you want to send
  delay(100);
  mySerial.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
}
</code></pre>
 41696: <p>There was not really a question, but I do notice there is no case's in your switch statement..</p>

<p>example from <a href="https://www.arduino.cc/en/Tutorial/SwitchCase" rel="nofollow noreferrer">here</a></p>

<pre><code>// do something different depending on the range value:
  switch (range) {
    case 0:    // your hand is on the sensor
      Serial.println("dark");
      break;
    case 1:    // your hand is close to the sensor
      Serial.println("dim");
      break;
    case 2:    // your hand is a few inches from the sensor
      Serial.println("medium");
      break;
    case 3:    // your hand is nowhere near the sensor
      Serial.println("bright");
      break;
  }
  delay(1);        // delay in between reads for stability
</code></pre>
