Ni yanfang
Member level 3
- Joined
- Jul 30, 2013
- Messages
- 59
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 6
- Activity points
- 432
Hi I am using AT89C51 mcu connect with gsm modem . I need to write AT command using c language to run my program. But the code is not working and can not send sms to mobile. Kindly che check for me the below code. I just need press p1^3 button then the prgram can send sms. I did not need receive reply because i did not connect LCD. And i have not ideal how to add LED p3^6 in this program to indicate on and off. This means led on when sending sms or led off when device is not sending sms. Kindly help please.
Code C - [expand] 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 51 52 #include <reg51.h> #include <stdio.h> sbit irout=P1^3; sbit rs=P2^0; sbit rw=P2^1; sbit e=P2^2; void serial_init(void); void delay(int); void serial_init(void) { SCON = 0x50; TMOD = 0x20; TH1 = 0xFD; TR1 = 1; TI = 1; } void serial(void) interrupt 4 { unsigned int y[25]; if(RI==1) { y[25]=SBUF; RI=0; } } void delay(int n) { int i,j; for(i=0;i<n;i++) for(j=0;j<1000;j++); } void main(void) { IE=0x90; irout=1; irout=0; while(1) { if(irout==1) { delay(200); serial_init(); printf("AT+CMGF=1%c",13); delay(200); printf("AT+CMGS=\"92207869\"%c",13); delay(200); printf("Hi :-) GSM Modem Test"); delay(20); printf("%c",0x1A); delay(200); while(irout==1); } }}
Last edited by a moderator: