#include <TinyGPS++.h>
#include <SoftwareSerial.h>
int text_button = 6;
int tbv;
int call_button = 7;
int cbv;
TinyGPSPlus gps;
SoftwareSerial GLOBAL(2, 3);//tx rx
void setup() {
Serial.begin(9600);
GLOBAL.begin(9600);
pinMode(text_button, INPUT);
pinMode(call_button, INPUT);
}
void loop() {
tbv = digitalRead(text_button);
cbv = digitalRead(call_button);
while (GLOBAL.available()) {
gps.encode(GLOBAL.read());
}
if (tbv == 1) {
textlocation();
}
if (cbv == 1) {
Serial.println("Initializing...");
Serial.println("AT"); //Once the handshake test is successful, i t will back to OK
Serial.println("ATD+ +639480331916;"); // change ZZ with country code and xxxxxxxxxxx with phone number to dial
}
}
void textlocation() {
Serial.begin(9600);
Serial.println("Initializing...");
delay(1000);
Serial.println("AT"); //Once the handshake test is successful, it will back to OK
delay(500);
Serial.println("AT+CMGF=1\r"); // Configuring TEXT mode
delay(500);
Serial.println("AT+CMGS="+639480331916"\r");//change ZZ with country code and xxxxxxxxxxx with phone number to sms
delay(500);
Serial.println("help me!"); //text content
Serial.print("Latitude: ");
Serial.print(gps.location.lat(), 6);
Serial.print("\n Longitude: ");
Serial.println(gps.location.lng(), 6);
Serial.println("\r");
Serial.print("Google Maps");
Serial.print(gps.location.lat(), 6);
Serial.print('+');
Serial.print(gps.location.lng(), 6);
Serial.write(26);
}