-
Notifications
You must be signed in to change notification settings - Fork 1
/
Test.ino
50 lines (38 loc) · 1.33 KB
/
Test.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Code Written by DPV TECHNOLOGY. WE have explained all the code in the grey comments.
we recommend you to go over the code, examine it, play with it, improve it and modify it according to your needs.
SUBSCRIBE DPV TECHNOLOGY:
https://www.youtube.com/dpvtechnology?sub_confirmation=1
*/
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2,3);
void setup()
{
mySerial.begin(9600); // Setting the baud rate of GSM Module
Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
delay(100);
}
void loop()
{
if (Serial.available()>0)
switch(Serial.read())
{
case 's':
mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000); // Delay of 1 second
mySerial.println("AT+CMGS=\"+91XXXXXXXXXX\"\r"); // Replace x with mobile number
delay(1000);
mySerial.println("HEI DPV,THIS IS FROM GSM");// The SMS text you want to send
delay(100);
mySerial.println((char)26);// ASCII code of CTRL+Z for saying the end of sms to the module
delay(1000);
break;
case 'r':
mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
delay(1000);
//Serial.println("Done");
break;
}
if (mySerial.available()>0){
Serial.write(mySerial.read());
}
}