Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:6ce4767a3c30
- Child:
- 1:e2fc45717136
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Oct 09 13:08:25 2015 +0000
@@ -0,0 +1,45 @@
+#include "mbed.h"
+char a=0x1A,e=0x22,c=0x0D,v=0x0A;
+char phone_no[] = "9805073071"; //enter your phone number
+char* txt;
+Serial GSM(p9,p10,txt); // tx, rx
+int select=1; //select 1 for message and 0 for call
+
+
+
+ ///////////////////////////////////////////////////////////////////////////////////
+ void GSM_SMS(char phone_no[])
+ {wait(2);
+GSM.printf("AT+CMGF=1\n\r"); //set gsm to text mode
+wait(3);
+GSM.printf("AT+CMGS=%c%s%c\n\r",e,phone_no,e); //for messaging AT+CMGS=\"phone_no\" command is send where e=0x22 (hex code of \" )
+wait(2);
+txt="message"; //enter message to be sent
+GSM.printf("\n%s",txt); //sends message
+wait(0.5);
+GSM.printf("%c",a); //sends command for end of message
+GSM.printf("%c",c); //carriage return in hex
+GSM.printf("%c",v); //line feed in hex
+//the 0D0A part of charactersis the signal for end of line.
+}
+////////////////////////////////////////////////////////////////////////////////////
+void GSM_CALL(char phone_no[])
+{ myled=1 ;
+GSM.printf("ATD");
+GSM.printf(phone_no);
+GSM.printf(";\n\r");
+wait(15);
+ GSM.printf("ATH");
+wait(2);
+ }
+ /////////////////////////////////////////////////////////////////////////////////
+ int main()
+{GSM.baud(9600);
+GSM.printf("AT\n\r");//to wakeup gsm
+if(select==0)
+{
+ led2=1;
+ GSM_CALL(phone_no);}
+if(select==1)
+{GSM_SMS(phone_no);}
+ }
\ No newline at end of file