jayanth.devarayanadurga
Banned
- Joined
- Dec 4, 2012
- Messages
- 4,280
- Helped
- 822
- Reputation
- 1,654
- Reaction score
- 791
- Trophy points
- 1,393
- Location
- Bangalore, India
- Activity points
- 0
Zip and post your Proteus file and mikroC project files. I don't have time to draw it.
Try this.
Try this.
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 82 void sms_AT (){ UART1_Write_Text("AT"); UART1_Write(13); //Enter key = CF + LF UART1_Write(10); //delay_ms(2000); } void sms_mode(){ UART1_Write_Text("AT+CMGF=1"); //text mode sms UART1_Write(13); //Enter key = CF + LF UART1_Write(10); delay_ms(1000); } void sms_nr(){ UART1_Write_Text("AT+CMGS=\"0720050752\""); //phone number UART1_Write(13); //Enter key = CF + LF UART1_Write(10); delay_ms(2000); } void sms_msg(){ UART1_Write_Text("Senzor activ!"); //sms text UART1_Write(13); UART1_Write(0x1A); // <ctrl-z> UART1_Write(13); } unsigned char uart_rd[3], send_sms = 0; unsigned int i = 0, m = 1; void main(){ TRISA = 0xFF; TRISB = 0xFA; PORTB.B0 = 1; Delay_ms(1000); PORTB.B0 = 0; UART1_Init(9600); // Initialize UART module at 9600 bps Delay_ms(100); // Wait for UART module to stabilize while(1){ if(PORTB.B5){ Delay_ms(50); if(PORTB.B5){ send_sms = 1; } } if(send_sms){ sms_AT(); // If data is ready, read it: if (UART_Data_Ready() == 1){ uart_rd[i++] = UART_Read(); uart_rd[i] = '\0'; } m = strcmp(uart_rd, "OK"); if(m == 0){ sms_mode(); sms_nr(); sms_msg(); PORTB.B0 = 1; Delay_ms(1000); PORTB.B0 = 0; } send_sms = 0; m = 1; } } }
Last edited: