#include <SoftwareSerial.h>
#include <SPI.h>
#include <LiquidCrystal.h>
SoftwareSerial mySerial(1, 0);
LiquidCrystal lcd(9, 8, 6, 5, 3, 2);
char b;
String textForSMS;
String f1001 = "+8754618545";
String f1002 = "+8217738371";
String f1003 = "+6379869595";
String f1004 = "+6379042752";
String f1005 = "+9487713067";
void setup() {
pinMode(10, OUTPUT);
lcd.begin(16, 2);
Serial.begin(9600);
mySerial.begin(9600);
Serial.println("Logging time completed!");
}
void loop() {
uint8_t buf[1];
uint8_t buflen = sizeof(buf);
if (mySerial.available() > 0) {
char receivedChar = mySerial.read();
if (receivedChar == 'a') {
sendSMS();
output();
}
}
}
void sendSMS() {
textForSMS = "\nPLEASE RESCUE ME, I AM IN PROBLEM. '\n' MY CURRENT LOCATION IS: https://goo.gl/maps/search/query?=lat,lon";
sendsms(textForSMS, f1001);
Serial.println(textForSMS);
Serial.println("Message 1 sent.");
delay(2000);
sendsms(textForSMS, f1002);
Serial.println(textForSMS);
Serial.println("Message 2 sent.");
delay(2000);
sendsms(textForSMS, f1003);
Serial.println(textForSMS);
Serial.println("Message 3 sent.");
delay(2000);
sendsms(textForSMS, f1004);
Serial.println(textForSMS);
Serial.println("Message 4 sent.");
delay(2000);
sendsms(textForSMS, f1005);
Serial.println(textForSMS);
Serial.println("Message 5 sent.");
delay(2000);
}
void sendsms(String message, String number) {
String mnumber = "AT+CMGS=\"" + number + "\"";
mySerial.println("AT+CMGF=1\r");
delay(1000);
mySerial.println(mnumber);
delay(1000);
mySerial.println(message);
delay(1000);
mySerial.println((char)26);
delay(1000);
mySerial.println();
delay(100);
}
void output() {
lcd.setCursor(0, 0);
lcd.print("WOMAN IS ");
lcd.setCursor(2, 1);
lcd.print(" IN DANGER");
for (int i = 0; i < 100; i++) {
digitalWrite(6, HIGH); // turn on the light
delay(250);
digitalWrite(6, LOW); // turn off the light
delay(250);
}
}