Emmanuel1992
Junior Member level 2
Dear member any one who know how to interface gsm modem with pic16f877a to turn on/off LED because I have trying to program a code for this stuff by using mikroC compiler but i doesn't work as am expected to work.
My code it's below.
Any one who can correct my code please because am suppose to submit it soon.
My code it's below.
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 53 54 55 56 57 58 59 60 61 62 63 64 sbit LED at RC1_bit; char lock[] = "LED ON"; char Read; void main() { UART1_Init(9600); delay_ms(1); UART1_Write_Text("AT"); UART1_Write(0x0D); Delay_Ms(100); UART1_Write_Text("ATE0"); UART1_Write(0x0D); Delay_Ms(100); UART1_Write_Text("AT+CMGF=1"); UART1_Write(0x0D); Delay_Ms(100); UART1_Write_Text("AT+CMGS=717677776"); UART1_WRITE(0X0D); Delay_Ms(100); TRISA=0Xff; TRISC.F1=0; while(Read!= '\0' || Read != '\n' ) { unsigned short int Index=0; char Byte[20]; Byte[Index] = Read; Index++; } while(1){ if(UART1_Data_Ready()==1) { Read = UART1_Read(); if(strcmp(Read,"LED ON")==0) { delay_ms(1); LED==1 ; //lock on. delay_ms(2000); UART1_WRITE_TEXT("AT+CMGS="); delay_ms(1); UART1_WRITE(0X22); //" delay_ms(1); UART1_WRITE_TEXT("0123456789"); //MY NUMBER delay_ms(1); UART1_WRITE(0X22); //" UART1_WRITE(0X0D); //<CR> means enter delay_ms(1); UART1_WRITE_TEXT("LED IS ON"); UART1_WRITE(0X0D); //<CR> means enter delay_ms(1); UART1_WRITE(26); delay_ms(1); UART1_WRITE(0X0D); //<CR> means enter delay_ms(1); } } }
Any one who can correct my code please because am suppose to submit it soon.
Last edited by a moderator: