/******************************************************************************
Program for VTS_with_GSM
Program written by Engr. Mithun K. Das
Email: mithun060@gmail.com
MCU: PIC18F4550A; X_Tal: 20MHz(external)
Date: 23/11/2013;
******************************************************************************/
// LCD module connections
sbit LCD_RS at RB7_bit;
sbit LCD_EN at RB6_bit;
sbit LCD_D4 at RB5_bit;
sbit LCD_D5 at RB4_bit;
sbit LCD_D6 at RB3_bit;
sbit LCD_D7 at RB2_bit;
sbit LCD_RS_Direction at TRISB7_bit;
sbit LCD_EN_Direction at TRISB6_bit;
sbit LCD_D4_Direction at TRISB5_bit;
sbit LCD_D5_Direction at TRISB4_bit;
sbit LCD_D6_Direction at TRISB3_bit;
sbit LCD_D7_Direction at TRISB2_bit;
// End LCD module connections
unsigned char uart_rd=0;
void Send_ATcmd()
{
UART1_Write((char)13); //try it using comment and uncomment this line
UART1_Write((char)10);
UART1_Write((char)'A');
UART1_Write((char)'T');
UART1_Write((char)13); //try it using comment and uncomment this line
UART1_Write((char)10);
}
void Send_AT_CMGF()
{
UART1_Write((char)'A');
UART1_Write((char)'T');
UART1_Write((char)'+');
UART1_Write((char)'C');
UART1_Write((char)'M');
UART1_Write((char)'G');
UART1_Write((char)'F');
UART1_Write((char)'=');
UART1_Write((char)'1');
UART1_Write((char)13); //try it using comment and uncomment this line
UART1_Write((char)10);
}
void Send_AT_CMGS()
{
UART1_Write((char)'A');
UART1_Write((char)'T');
UART1_Write((char)'+');
UART1_Write((char)'C');
UART1_Write((char)'M');
UART1_Write((char)'G');
UART1_Write((char)'S');
UART1_Write((char)'=');
UART1_Write((char)'"');
UART1_Write((char)'0');
UART1_Write((char)'1');
UART1_Write((char)'7');
UART1_Write((char)'2');
UART1_Write((char)'2');
UART1_Write((char)'4');
UART1_Write((char)'4');
UART1_Write((char)'8');
UART1_Write((char)'2');
UART1_Write((char)'7');
UART1_Write((char)'0');
UART1_Write((char)'"');
UART1_Write((char)13); //try it using comment and uncomment this line
UART1_Write((char)10);
}
void Send_SMS()
{
UART1_Write((char)'T');
UART1_Write((char)'E');
UART1_Write((char)'S');
UART1_Write((char)'T');
UART1_Write(26);// send ctrl + Z
Delay_ms(2000);
UART1_Write((char)13); //try it using comment and uncomment this line
UART1_Write((char)10);
}
void main()
{
TRISC7_bit = 1;
TRISC6_bit = 0;
ADCON1 = 0xFF;
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Delay_ms(1000);
UART1_init(114200);
delay_ms(3000);
while(1)
{
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"Sending Data...");
Delay_ms(2000);
Send_ATcmd();
uart_rd = UART1_Read();
Lcd_Out(2,1,uart_rd);
Delay_ms(500);
Send_AT_CMGF();
uart_rd = UART1_Read();
Lcd_Out(2,1,uart_rd);
Delay_ms(500);
Send_AT_CMGS();
uart_rd = UART1_Read();
Lcd_Out(2,1,uart_rd);
Delay_ms(500);
Send_SMS();
uart_rd = UART1_Read();
Lcd_Out(2,1,uart_rd);
Delay_ms(2000);
}//while
}//void