Hi guys!
I couldn't fully grasp the commands of gsm shield and serial monitor (but I've read a lot about it believe me), so I have trouble with changing the recepient phone number of my messages using the arduino IDE serial monitor send thingy.
I'm new to this forum and hobby (arduino rocks btw), and I'm a newbie programmer. I'm very sorry if this is a dumb question and if my code is bad. Please help me
#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);
String readString;
int number;
void setup()
{
 Serial.begin(9600);
 Serial.println("Cellphone number");
 while (Serial.available()) {
  char c = Serial.read(); //gets one byte from serial buffer
  readString += c; //makes the string readString
  delay(2); //slow looping to allow buffer to fill with next character
 }
 if (readString.length() > 0) {
  Serial.println(readString);
  number = readString.toInt(); //convert readString into a number
Â
  readString=""; //empty for next input
 }
 SIM900.begin(19200);
 SIM900power();Â
 delay(20000); // give time to log on to network.
}
void SIM900power()
{
 digitalWrite(9, HIGH);
 delay(1000);
 digitalWrite(9, LOW);
 delay(5000);
}
void sendSMS()
{
 SIM900.print("AT+CMGF=1\r");                            // AT command to send SMS message
 delay(100);
 SIM900.println("AT + CMGS = \"+number\""); //phone number. this is where my problem is T_T
 delay(100);
 SIM900.println("Hello, world!!!!.");    // message to send
 delay(100);
 SIM900.println((char)26);           // End AT command with a ^Z, ASCII code 26
 delay(100);
 SIM900.println();
 delay(5000);                  // give module time to send SMS
 SIM900power();                 // turn off module
}
void loop()
{
 sendSMS();
 do {} while (1);
}
is this correct?
And what do you mean by 'it'? Sorry.
Just tested it and it's not sending the message. It's not probably storing the number I send in the serial monitor
Here is the code. I removed the conversion. Should I keep it? I can't still send messages btw
#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);
String readString;
void setup()
{
 Serial.begin(9600);
 Serial.println("Cellphone number"); // so I can keep track of what is loaded
 while (Serial.available()) {
  char c = Serial.read(); //gets one byte from serial buffer
  readString += c; //makes the string readString
  delay(2); //slow looping to allow buffer to fill with next character
 }
 if (readString.length() > 0) {
  Serial.println(readString); //so you can see the captured string
Â
  // auto select appropriate value, copied from someone elses code.
Â
  readString=""; //empty for next input
 }
 SIM900.begin(19200);
 delay(20000); // give time to log on to network.
}
void sendSMS()
{
 SIM900.print("AT+CMGF=1\r");                            // AT command to send SMS message
 delay(100);
 SIM900.println("AT + CMGS = \"" +61+readString +"\"");
 delay(100);
 SIM900.println("Hello, world. This is a text message from an Arduino!!");    // message to send
 delay(100);
 SIM900.println((char)26);           // End AT command with a ^Z, ASCII code 26
 delay(100);
 SIM900.println();
 delay(5000);                  // give module time to send SMS
}
void loop()
{
 sendSMS();
 do {} while (1);
}
I also noticed that the data i sent is not displayed even though it's supposed to be captured. Is this part of the issue? thanks for your patience
Thanks for the help! It worked. Never expected the fix was so simple sobs
#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);
String readString;
void setup()
{
 Serial.begin(9600);
 while (!Serial.available())
 {
   Serial.println("Cellphone number"); // i can't find a better way so here it is atm
   delay (500);
 }
 while (Serial.available()) {
  char c = Serial.read(); //gets one byte from serial buffer
  readString += c; //makes the string readString
  delay(2); //slow looping to allow buffer to fill with next character
 }
 if (readString.length() > 0) {
  Serial.print(readString);
  readString=""; //empty for next input
 }
 SIM900.begin(19200);
 delay(20000); // give time to log on to network.
}
void sendSMS()
{
 SIM900.print("AT+CMGF=1\r");                            // AT command to send SMS message
 delay(100);
 SIM900.println("AT + CMGS = \""+readString +"\"");
 delay(100);
 SIM900.println("Hello, world. This is a text message from an Arduino Uno.");    // message to send
 delay(100);
 SIM900.println((char)26);           // End AT command with a ^Z, ASCII code 26
 delay(100);
 SIM900.println();
 delay(5000);                  // give module time to send SMS
}
void loop()
{
 sendSMS();
 do {} while (1);
}