
#include <SoftwareSerial.h>
SoftwareSerial mySerial(9,10);
char msg;
int buttonred=5;
int buttonblue=7;
int buttongreen=6;
void setup()
{
  pinMode(buttonred,INPUT);
  pinMode(buttonblue,INPUT);
  pinMode(buttongreen,INPUT);
  mySerial.begin(9600);   // Setting the baud rate of GSM Module  
  Serial.begin(9600);// Setting the baud rate of Serial Monitor (Arduino)
  Serial.println("press button"); // Skip this if you want to it doesn't really matter
}

void loop()
{
  if(digitalRead(buttonred)==HIGH){
    
    Serial.println("button red pressed");
    delay(1000);
    SendMessagered();  
  }
 if(digitalRead(buttonblue)==HIGH){
Serial.println("button blue pressed");
    delay(1000);
    SendMessageblue();  
}
if(digitalRead(buttongreen)==HIGH){
  Serial.println("button green pressed");
    delay(1000);
    SendMessagegreen();

  
}
 if (mySerial.available()>0)
 Serial.write(mySerial.read());
}

void SendMessagered()//
{
  mySerial.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
  delay(1000);  // Delay of 1000 milli seconds or 1 second

  mySerial.println("AT+CMGS=\"+30xxxxxxxxxx\"\r"); // Replace x with mobile number and the +30 with whatever you have as the code where you live in
  delay(1000);

  mySerial.println("EMERGENCY!!!");// The SMS text you want to send
  delay(100);
   mySerial.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
}

void SendMessageblue()
{
  mySerial.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
  delay(1000);  // Delay of 1000 milli seconds or 1 second

  mySerial.println("AT+CMGS=\"+30xxxxxxxxxx\"\r"); // Replace x with mobile number and the +30 with whatever you have as the code where you live in
  delay(1000);

  mySerial.println("I need to see you");// The SMS text you want to send
  delay(100);
   mySerial.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
}

void SendMessagegreen()
{
  mySerial.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
  delay(1000);  // Delay of 1000 milli seconds or 1 second

  mySerial.println("AT+CMGS=\"+30xxxxxxxxxx\"\r"); // Replace x with mobile number and the +30 with whatever you have as the code where you live in
  delay(1000);

  mySerial.println("I have to see you now!");// The SMS text you want to send
  delay(100);
   mySerial.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
}
