Skip to content

Instantly share code, notes, and snippets.

@OwiseKyawMinOo
Created November 1, 2018 16:22
Show Gist options
  • Save OwiseKyawMinOo/732307de38bc35afc3721dbe956e6942 to your computer and use it in GitHub Desktop.
Save OwiseKyawMinOo/732307de38bc35afc3721dbe956e6942 to your computer and use it in GitHub Desktop.
#include <SoftwareSerial.h>
SoftwareSerial SIM900A(10,11);
void setup()
{
SIM900A.begin(9600); // the baud rate of GSM Module
Serial.begin(9600); // the baud rate of Serial Monitor (Arduino)
Serial.println ("SIM900A Ready");
}
void loop()
{
if (Serial.available()>0)
switch(Serial.read())
{
case 's':
SendMessage();
break;
}
if (SIM900A.available()>0)
Serial.write(SIM900A.read());
}
void SendMessage()
{
Serial.println ("Sending Message");
SIM900A.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000);
Serial.println ("Set SMS Number");
SIM900A.println("AT+CMGS=\"+959441803792 \"\r"); //Mobile phone number to send message
delay(1000);
Serial.println ("Set SMS Content");
SIM900A.println("Good morning, how are you doing?");// Messsage content
delay(100);
Serial.println ("Finish");
SIM900A.println((char)26);// ASCII code of CTRL+Z
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment