**I want to send a text message to a list of numbers receiving from my java program. I can send a single sms, its is working perfect well. But how to send sms to many numbers at once. I have given arduino code and java code below. It works well . **
Please help me to send an sms to many numbers with java and arduino , sms should be sent at once
Arduino code
#include <SoftwareSerial.h>
#include <String.h>
SoftwareSerial mySerial(40, 41);
void setup() {
mySerial.begin(19200);
Serial.begin(9600);
}
String number;
String smsTxt;
void loop() {
if (Serial.available()>0)
{
String inData = Serial.readString();
number = inData.substring(0,13);
smsTxt = inData.substring(14,28);
}
}
void SendTextMessage()
{
mySerial.print("AT+CMGF=1\r"); //Because we want to send the SMS in text mode
delay(100);
mySerial.println("AT + CMGS = ""+number+""");//send sms message, be careful need to add a country code before the cellphone number
delay(100);
mySerial.println(""+smsTxt+"");//the content of the message
delay(100);
mySerial.println((char)26);//the ASCII code of the ctrl+z is 26
delay(100);
mySerial.println();
}
Java code (only the string sending code)
String mob = "+94771144786";
String txt = "Access denied ";
String x = " "+mob+" "+txt+" ";
serialPort.writeString(x);