tofigg
Junior Member level 1
![Junior Member level 1](/styles/images/ranks/clevel1.gif)
hello everybody
im doing project about controlling relays by sms and i wrote my code and couldnt get it work and i need help plz if anyone know anything about it help me
i should read the sms and then check if its a valid command from the user then operate the specific order for that command
external ocs :7.372M
buad rate: 9600
gsm modem: sim300
pic16f887
im doing project about controlling relays by sms and i wrote my code and couldnt get it work and i need help plz if anyone know anything about it help me
i should read the sms and then check if its a valid command from the user then operate the specific order for that command
external ocs :7.372M
buad rate: 9600
gsm modem: sim300
pic16f887
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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 unsigned char uart_rd; unsigned char text; char K; unsigned char a[4]; int i=0; void SMS(){ for(i=0;i<3;i++) { a[i]=UART1_Read(); } if ((a[0] == 'A') & (a[1] == 'B') & (a[2] == 'C')) PORTD=1; if ((a[0] == 'X') & (a[1] == 'Y') & (a[2] == 'Z')) PORTA=1; UART1_Write_Text("AT+CMGD=1"); UART1_Write(13); UART1_Write(10); Delay_ms(500); } void main() { PORTA = 0xFF; PORTB = 0xFF; ANSEL = 0; // Configure AN pins as digital I/O ANSELH = 0; TRISD = 0x00; // making port as output PORTD = 0x00; // making port as output UART1_Init(9600); Delay_ms(1000); UART1_Write_Text("AT"); UART1_Write(13); UART1_Write(10); Delay_ms(2000); UART1_Write_Text("AT+CMGF=1"); UART1_Write(13); UART1_Write(10); Delay_ms(2000); UART1_Write_Text("AT+CMGD=1"); UART1_Write(13); UART1_Write(10); Delay_ms(500); while (1) { UART1_Write_Text("AT+CMGR=1"); UART1_Write(13); UART1_Write(10); Delay_ms(500); UART1_Read_Text(a, "*", 200); // reads text until '*' is found { SMS(); } UART1_Write_Text("AT+CMGD=1"); UART1_Write(13); UART1_Write(10); Delay_ms(100); } }