Can we use AT commands to input array by using user defined number to send sms?
I mean
AT+CMGS="array[]";
If no what is alternative?
Can you please explain more clearly what you are asking ?
Do you want to copy a string from an array or copy it to an array maybe ?
Can we use AT commands to input array by using user defined number to send sms?
I mean
AT+CMGS="array[]";
If no what is alternative?
Maybe. Probably what you want is something like:
char cmd[80];
sprintf(cmd, "AT+CMGS=\"%s\"", phoneNumber);
where
char *phoneNumber = "123456789"; // the phone number to send to goes here
It is not working,is there any other option?
i want to feed user inputted mob no. to the at commands.
Post the full code that does not work and describe what happens when you run it.
#include<SIM900.h>
#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8 );
void setup()
{
SIM900.begin(19200);
delay(200);
}
void randomnum()
{
char num[20];
char *phoneNumber = "1234567890";
SIM900.print("AT+CMGF=1\r");
sprintf(num, "AT+CMGS="%s"", phoneNumber);
delay(50);
SIM900.println("America");
delay(50);
SIM900.println((char)26);
delay(50);
SIM900.println("Sent");
delay(5000);
}
void loop()
{
randomnum();
}
This is code ,I am sending message to user inputed cellphone number which I am asking person to enter from my touchscreen. My touchscreen is working fine. My GSM code compiles also. But GSM is not giving output since it donot send SMS. It's compiling well. If I directly give like pre-provided number ,
SIM900.println("AT+CMGS="+1234567890"");
It works and sends sms. but if I input the cell number it doesn't. Please help.
Where is the code to get the number from the user ?
What do you see if you print num after the sprintf() ?
I don't get what you mean.I don't see any error but message is not sent
arduinogeekiam:
I don't get what you mean.I don't see any error but message is not sent
I was not asking about errors.
Please post your code that gets the number from the user.
In your program please print the value of the num variable after you have done the sprintf() and post the result here.
sprintf(num, "AT+CMGS=\"%s\"", phoneNumber);
Don't you suppose that you should send this command, after creating it?
Your num array is too small. You need to make it one larger for the null terminator.