Thursday, 27 February 2014

LPG gas maintenance tips, LPG gas repairing issues

These are some of the safety considerations that you need to follow


1. Always the regulator should be off after the cooking.

2. Don't use ordinary flexible tube to connect stove with cylinder or to connect burner with gas line.

3. Check leakages regularly that is weekly once by soap water or surf water or any soap oil, you can find leakages by pouring this liquid on joints, you see bubbles then there is a  leakage other wise there is no leakage.
4. Open windows and doors and make kitchen well ventilated while cooking.

5. The gas will not spread up words it self if it leaks, it will be revolved in the room with 3 to 4 foot height from ground.

6. Be care full while leakage and after leakage, don't switch on any electrical buttons a small spark can cause a big blast.


Remaining data will be updated soon.....

Tuesday, 25 February 2014

code for anti theft tracking system, fingerprint protected anti theft tracking system code, embedded code, project code

This is the code i am sending it is having gsm.h, lcd.h, main.c, uart0.h, uart.h files.


  1. main.c
#include<lpc214x.h>


#include<string.h>
#include"lcd.h"
#include"uart0.h"
#include"uart1.h"
#include"gsm.h"

unsigned char GSM_recive,newmsg=0;
extern unsigned char msg[50],mobilenum[11];
unsigned char store_m[11],vib=0,gpsdata,GPSvalue[50],Longitude[50];

void GPS_read (void);

#define  motor           0x00020000         // p0.17        pin no=35  (in pin)
#define  ir           0x00040000        // p0.18      pin no=45  (in pin)
#define  sw           0x00080000        // p0.19      pin no=45  (in pin)
#define  enrol           0x00100000        // p0.20      pin no=45  (in pin)

#define  buzz            0x00800000
#define  gsm             0x00000004         
#define  gps             0x00000008


#define  Motor_ON     IOSET0 |= motor
#define  Motor_OFF    IOCLR0 |= motor

#define  buzz_ON      IOCLR0 |=buzz
#define  buzz_OFF     IOSET0 |= buzz

#define  gsm_on       IOSET0 |= gsm
#define  gsm_off      IOCLR0 |= gsm

#define  gps_on       IOSET0 |= gps
#define  gps_off      IOCLR0 |= gps

unsigned char uart0_rx,t1,t2,t3,suc=0,ide=0,id1=0;

unsigned char baudrate[14]={0xef,0x01,0xff,0xff,0xff,0xff,0x01,0x00,0x05,0x0e,0x04,0x01,0x00,0x19};
unsigned char enroll[12]={0xEF,0X01,0XFF,0XFF,0XFF,0XFF,0X01,0X00,0X03,0X01,0X00,0X05};   
unsigned char generate_ch[13]={0xEF,0X01,0XFF,0XFF,0XFF,0XFF,0X01,0X00,0X04,0x02,0X01,0X00,0X08};  
unsigned char generate_ch1[13]={0xEF,0X01,0XFF,0XFF,0XFF,0XFF,0X01,0X00,0X04,0x02,0X02,0X00,0X09};  
unsigned char un_cmd[12]={0xef,0x01,0xff,0xff,0xff,0xff, 0x01,0x00,0x03,0x05,0x00,0x09 };
unsigned char store[12]={0xEF,0X01,0XFF,0XFF,0XFF,0XFF,0X01,0X00,0X06,0X06,0X02,0x00};
unsigned char identify[17]={0xef,0x01,0xff,0xff,0xff,0xff,0x01,0x00,0x08,0x1b,0x01,0x00,0x00,0x01,0x01,0x00,0x27};

unsigned int fp_i=0,fp[20],fp_j=0;
unsigned int rec=0x00,dummy=0x0f,id; 


void clearfp(void);
void enroll_finger(void);
void identify_finger(void);


void main_delay( unsigned int value )
{
 unsigned int ui_temp1,ui_temp2;
 for(ui_temp1=0;ui_temp1<value;ui_temp1++)
 for(ui_temp2=0;ui_temp2<5000;ui_temp2++);
}

void UART0_irq (void) __irq               
{
 while (!(U0LSR & 0x01));     // Wait RXD Receive Data Ready
 GSM_recive=U0RBR; 
 
 if(GSM_recive=='+')
 {
  newmsg=1;
  VICIntEnable = 0x00000000;   //interrupt Enable 
  U0IER=0;  // Clear the interrupt;
  VICVectAddr = 0x00000000; // interrupt address;
 }
 VICVectAddr = 0x00000000;   //Dummy write to signal end of interrupt                                                                                  
}

void UART1ISR (void) __irq
{
 while (!(U1LSR & 0x01));
 fp[fp_j]=U1RBR;
 fp_j++;
 VICVectAddr = 0x00000000;   //Dummy write to signal end of interrupt   
}

void EXTINT0_ISR (void)  __irq    //external interrupt 0 EINT0 pin0 16
{
 vib=1;
 VICVectAddr = 0x00000000; 
 EXTINT =0x01;
}

void uart0_irq_init(void)
{
 VICVectCntl1 = 0x00000026;            
 VICVectAddr1 = (unsigned long)UART0_irq;
 VICIntEnable |= 0x00000040;         
 U0IER=0x01;          
}

void uart1_irq_init(void)
{
 VICVectCntl0 = 0x00000027;    
 VICVectAddr0 = (unsigned)UART1ISR;
 VICIntEnable = 0x00000080;
 U1IER=0x05;
}

void  EXTINT0_init()
{
 VICVectCntl2 = 0x0000002E; 
 VICVectAddr2 = (unsigned)EXTINT0_ISR; 
 VICIntEnable |=0x00004000;
 PINSEL1 |= 0x00000001; 
 EXTINT |=0x01;
 EXTMODE |=0x01;
 EXTPOLAR |=0x00;
}

int main()
{
 char vh_status=0,glass_b=0,vh_s=0;  

 IODIR0 |=gsm;
 gsm_off;

 IODIR0 |=gps;
 gps_off;

 IODIR0 |=motor;
 Motor_OFF;

 IODIR0 |=buzz;
 buzz_OFF;

 lcd_init();
 uart0_init();
 uart1_init();
 lcd_cmd(0x01);
 lcd_puts("vehicle security "); //Vehicle security
 lcd_cmd(0xc0);
 lcd_puts("     system");
 main_delay(2000);

 gsm_on;
 gps_off;
 gsm_check();
 gsm_init();
 gsm_clear_msg(1);

 uart0_irq_init();

 lcd_cmd(0x01);
 lcd_puts("Store Ph.No");

 while(newmsg==0);
 {
  newmsg=0;
  lcd_cmd(0x01);
  lcd_puts("msg.........");
  main_delay(2000);
  U0IER=0x00;
  gsm_mes_read();
  lcd_cmd(0x01);
  lcd_puts(mobilenum);
  gsm_delay(2000);
  store_m[0]=mobilenum[0];
  store_m[1]=mobilenum[1];
  store_m[2]=mobilenum[2];
  store_m[3]=mobilenum[3];
  store_m[4]=mobilenum[4];
  store_m[5]=mobilenum[5];
  store_m[6]=mobilenum[6];
  store_m[7]=mobilenum[7];
  store_m[8]=mobilenum[8];
  store_m[9]=mobilenum[9];
  store_m[10]=mobilenum[10];

  U0IER=0x01;  
  main_delay(2000);
 }

 EXTINT0_init();
 uart1_irq_init();

 start:

 lcd_cmd(0x01);
 lcd_puts("vehicle security "); //Vehicle security
 lcd_cmd(0xc0);
 lcd_puts("     system");
 main_delay(5000);

 lcd_cmd(0x01);
 lcd_puts(" PUT UR FINGER");

 while(1)
 {
  if(newmsg==1)
  {
   char i;
   
   newmsg=0;
   gsm_mes_read();
   main_delay(1000);

lcd_cmd(0x01);
 lcd_puts("vehicle security "); //Vehicle security
 lcd_cmd(0xc0);
 lcd_puts("     system");
   
   if(!strcmp(msg,"STOP"))
   {
    if(!strcmp(mobilenum,store_m))
 {
     buzz_ON ;
  vh_status=1;
     for(i=0;i<5;i++)
  {
   lcd_cmd(0x01);
   lcd_puts("vh going to be ");
   lcd_cmd(0xc0);
   lcd_puts("stop....");
   main_delay(500);
  }
  Motor_OFF;
  U0IER=0x00;
  gsm_send_num_mesg_data(mobilenum,Longitude,"vh stoped");
  main_delay(1500);
     U0IER=0x01;
  lcd_cmd(0x01);
  lcd_puts("Door locked");
  lcd_cmd(0xc0);
  lcd_puts("vh ctrl by user");
    }
 else
 {
  lcd_cmd(0x01);
  lcd_puts("Unauthorized ");
  lcd_cmd(0xc0);
  lcd_puts("       Access");
  main_delay(500);
  goto start;
 }
   }
   if(!strcmp(msg,"LOCATION"))
   {
    if(!strcmp(mobilenum,store_m))
 {
     U0IER=0x00;
     gsm_send_num_mesg(mobilenum,Longitude);
  gsm_delay(2000);
     U0IER=0x01;
     
     lcd_cmd(0x01);
     lcd_puts("vehicle security "); //Vehicle security
     lcd_cmd(0xc0);
     lcd_puts("     system");
     main_delay(1000); 

  if(vh_status==1)
     {
      lcd_cmd(0x01);
      lcd_puts("Door locked");
  lcd_cmd(0xc0);
  lcd_puts("vh ctrl by user");
     }
    }
 else
 {
  lcd_cmd(0x01);
  lcd_puts("Unauthorized P");
  lcd_cmd(0xc0);
  lcd_puts(" Try to Access");
  main_delay(1500);
  goto start;
 }
   }
   if(!strcmp(msg,"START"))
   {
    if(!strcmp(mobilenum,store_m))
 {
     vh_status=0;
  U0IER=0x00;
     gsm_send_num_mesg_data(mobilenum,Longitude,"vh start");
  gsm_delay(2000);
     U0IER=0x01;
  lcd_cmd(0x01);
     lcd_puts("vh start by user");
goto start;
    }
 else
 {
  lcd_cmd(0x01);
  lcd_puts("Unauthorized ");
  lcd_cmd(0xc0);
  lcd_puts("       Access");
  main_delay(1500);
  goto start;
 }
   } 
  }

if((IOPIN0&ir)!=0 && vh_status==0 && vh_s==0)
  {
    //U0IER=0x00;
   //enroll_finger();
// U0IER=0x01;

U0IER=0x00; 
identify_finger();
U0IER=0x01; 

if( ide==1)
   {
ide=0; 
vh_s=1; 
    Motor_ON ;
    U0IER=0x00; 
gsm_off;
gps_on; 
GPS_read();
uart0_init(); 
gps_off;
    gsm_on;
    gsm_send_num_mesg_data(store_m,Longitude,"authorized access");
    U0IER=0x01;  
}
else
{
U0IER=0x00; 
gsm_off;
gps_on; 
GPS_read();
uart0_init(); 
gps_off;
    gsm_on;
    gsm_send_num_mesg_data(store_m,Longitude,"unauthorized access");
    U0IER=0x01;  
   } 
    lcd_cmd(0x01);
    lcd_puts("vehicle security "); //Vehicle security
    lcd_cmd(0xc0);
    lcd_puts("     system"); 
  } 

if((IOPIN0&sw)==0&&vh_s==1)
  {
vh_s=0;  
while(!(sw&IOPIN0));
Motor_OFF ;
   goto start;
}

  if((IOPIN0&enrol)==0 && vh_s==1)
  {
while(!(enrol&IOPIN0));
    U0IER=0x00;
   enroll_finger();
U0IER=0x01;
lcd_cmd(0x01);
    lcd_puts("vehicle security "); //Vehicle security
    lcd_cmd(0xc0);
    lcd_puts("     system");  
  }

  if(vib==1)
  {
vib=0;
vh_s=0; 
   Motor_OFF ;
lcd_cmd(0x01);
lcd_puts("Accident ");
lcd_cmd(0xc0);
lcd_puts("   occurred");
main_delay(1000);
U0IER=0x00; 
gsm_off;
gps_on; 
GPS_read();
uart0_init(); 
gps_off;
   gsm_on;
   gsm_send_num_mesg_data(store_m,Longitude,"Accident occurred");
   U0IER=0x01;
   EXTINT0_init();
   goto start;
  }
  
  /*if(vh_status==1)
  {
   lcd_cmd(0x80);
   lcd_puts("                ");
   lcd_cmd(0xc0);
   lcd_puts("               ");
   lcd_cmd(0x80);
   lcd_puts("Door locked");
   lcd_cmd(0xc0);
   lcd_puts("vh cont by user");
   main_delay(800);
  }


  if(glass==1 && glass_b==0)   
  {
   glass_b=1;
   buzz_ON;
   glass=0;
   lcd_cmd(0x01);
   lcd_puts("  Glass Broken ");
   main_delay(1500);
   U0IER=0x00;
   gsm_send_num_mesg_data(store,Longitude,"Glass Broken");
   main_delay(1500);
   lcd_cmd(0x01);
   U0IER=0x01;
   goto start;
  }*/
 }
}









void GPS_read (void)
{
 unsigned char gps_i,gps_k;
 com_baudrate0(4800);
 while(1)
 {
  gpsdata =uart0_getch();
  if(gpsdata=='$')
  {
   gpsdata= uart0_getch();
   gpsdata= uart0_getch();

   if(uart0_getch()=='R')
   {
    if(uart0_getch()=='M')
    { 
     if(uart0_getch()=='C')
{
 gps_i=0;
 while(gps_i<45)
 {
  GPSvalue[gps_i]=uart0_getch();
  gps_i++;
 }
 GPSvalue[gps_i]='\0';
 gps_i=0;gps_k=0;
 main_delay(100);
 lcd_cmd(0x80);
   lcd_puts("                ");
   lcd_cmd(0xc0);
   lcd_puts("               ");
   lcd_cmd(0x80);
      lcd_puts("LT: ");
      Longitude[gps_k]='L';
 gps_k++;
 Longitude[gps_k]='T';gps_k++;
 Longitude[gps_k]=':';gps_k++;
 for(gps_i=14;gps_i<25;gps_i++)
 {
  lcd_data(GPSvalue[gps_i]);
  Longitude[gps_k]= GPSvalue[gps_i];
  gps_k++;
    //main_delay(100);
 }
 Longitude[gps_k]=' ';gps_k++;
 Longitude[gps_k]=' ';gps_k++;
 Longitude[gps_k]='L';gps_k++;
 Longitude[gps_k]='G';gps_k++;
 Longitude[gps_k]=':';gps_k++;
 lcd_cmd(0xc0);
      lcd_puts("LG: ");
 for(gps_i=27;gps_i<38;gps_i++)
 { 
  lcd_data(GPSvalue[gps_i]);
  Longitude[gps_k]=GPSvalue[gps_i];
  gps_k++;
  //main_delay(100);
 }
 Longitude[gps_k]='\0';
      gps_i=0;
 gps_k=0;
 main_delay(1000);

 break;
     }
    }
   }
  }
 }
}

void clearfp(void)
{
 unsigned char cl=0;
 while(cl<20)
 {
  fp[cl]=' ';
  cl++; 
 }
 fp_j=0;




void enroll_finger(void)
{
 lcd_cmd(0x01);                                                
 lcd_puts("Enrolling.....");
  main_delay(1000);
 fp_i=0;
 clearfp();
 while(fp_i<14)
 {
  uart1_putch( baudrate[fp_i]);
  fp_i++;
 }
 fp_j=0;
 fp[11]=0x00;
 while(fp_j==0);
 main_delay(500);                                       
 if(fp[11]==0x0a)
 {
  //lcd_cmd(0x01);                                                
  //lcd_puts("BAUDRATE SUCCESS");

  //main_delay(800);
 }
 else
 {
  lcd_cmd(0x01);                                                
  lcd_puts("BAUDRATE FAILED");
  main_delay(800);
goto end;
 } 

   fp_i=0;
   clearfp();
   while(fp_i<12)
   {
    uart1_putch(enroll[fp_i]);
    fp_i++;
   }
   fp_j=0;
   fp[9]=0x01;
   while(fp_j==0);
   main_delay(500);                                       
   if(fp[9]==0x00)
   {
   }
   else
   {
    lcd_cmd(0x01);                                                
    lcd_puts("ENROLL FAILED");
 main_delay(3000);
 goto end;
   }

   clearfp();
   fp_j=0;
   fp_i=0;
   while(fp_i<13)
   {
    uart1_putch(generate_ch[fp_i]);
    fp_i++;
   }
   fp_j=0;
   fp[9]=0x01;
   while(fp_j==0);
   main_delay(500);        
   if(fp[9]==0x00)
   {
   }
   else
   {
    lcd_cmd(0x01);                                                
    lcd_puts("ENROLL FAILED");
  main_delay(3000);
 goto end;
   }

   fp_i=0;
   clearfp();
   while(fp_i<12)
   {
    uart1_putch(enroll[fp_i]);
    fp_i++;
   }
   fp_j=0;
   fp[9]=0x01;
   while(fp_j==0);
   main_delay(500);       
   if(fp[9]==0x00)
   {
   }
   else
   {
    lcd_cmd(0x01);                                                
    lcd_puts("ENROLL FAILED");
 main_delay(3000);
   goto end;
   }

   clearfp();
   fp_j=0;
   fp_i=0;
   while(fp_i<13)
   {
    uart1_putch(generate_ch1[fp_i]);
    fp_i++;
   }
   fp_j=0;
   fp[9]=0x01;
   while(fp_j==0);
   main_delay(500);         
   if(fp[9]==0x00)
   {
   }
   else
   {
    lcd_cmd(0x01);                                                
    lcd_puts("ENROLL FAILED");
     main_delay(3000);
goto end;
   }

   clearfp();
   fp_j=0;
   fp_i=0;
   while(fp_i<12)
   {
    uart1_putch(un_cmd[fp_i]);
    fp_i++;
   }
   fp_j=0;
   fp[9]=0x01;
   while(fp_j==0);
   main_delay(500);        
   if(fp[9]==0x00)
   {
   }
   else
   { 
    lcd_cmd(0x01);                                                
    lcd_puts("ENROLL FAILED");
     main_delay(3000);
  goto end;
   }

   clearfp();
   fp_j=0;
   fp_i=0;
   while(fp_i<12)
   {
    uart1_putch(store[fp_i]);
    fp_i++;
   }
   uart1_putch(rec);
   uart1_putch(0x00);
   uart1_putch(dummy);
   fp_j=0;
   fp[9]=0x01;
   while(fp_j==0);
   main_delay(500);       
 
   if(fp[9]==0x00)
   {
    suc=1;
 lcd_cmd(0x01);                                                
    lcd_puts(" successfully ");
    lcd_cmd(0xc0);                                                
    lcd_puts("  Enrolled");
    main_delay(3000);       
    lcd_cmd(0x01);  
    lcd_puts(" ur id : "); 
lcd_data(rec/10+48);
    lcd_data(rec%10+48);  
id1++;
    rec++;
    dummy++;
    main_delay(3000);
goto end;
   }
   else
   {
    lcd_cmd(0x01);                                                
    lcd_puts("ENROLL FAILED");
  main_delay(3000);
goto end;
   } 
   end:
   main_delay(1);
}


void identify_finger(void)
{
 lcd_cmd(0x01);                              
 lcd_puts("IDENTIFYING...");
 main_delay(1000);
 fp_i=0;
 clearfp();
 while(fp_i<14)
 {
  uart1_putch( baudrate[fp_i]);
  fp_i++;
 }
 fp_j=0;
 fp[11]=0x00;
 while(fp_j==0);
 main_delay(1500);                                       
 if(fp[11]==0x0a)
 {
  //lcd_cmd(0x01);                                                
  //lcd_puts("BAUDRATE SUCCESS");

  //main_delay(800);
 }
 else
 {
  lcd_cmd(0x01);                                                
  lcd_puts("BAUDRATE FAILED");
  main_delay(800);
goto end; 
 } 

 fp_i=0;
 clearfp();
 while(fp_i<12)
 {
  uart1_putch(enroll[fp_i]);
  fp_i++;
 }
 fp_j=0;
 fp[9]=0x01;
 while(fp_j==0);
 main_delay(500);                                           
 if(fp[9]==0x00)
 {
 }
 else
 {
  lcd_cmd(0x01);                                                
  lcd_puts("IDENTIFY FAILED");
  
  main_delay(3000);       
  goto end;
 }

 clearfp();
 fp_j=0;
 fp_i=0;
 while(fp_i<13)
 {
  uart1_putch(generate_ch[fp_i]);
  fp_i++;
 }
 fp_j=0;
 fp[9]=0x01;
 while(fp_j==0);
 main_delay(500);         
 if(fp[9]==0x00)
 {
 }
 else
 {
  lcd_cmd(0x01);                                                
  lcd_puts("IDENTIFY FAILED");
  //lcd_puts1(0,4,"IDENTIFY FAILED..");
  main_delay(3000);       
  goto end;
 }
   

 clearfp();
 fp_i=0;  
 fp_j=0;
 while(fp_i<17)
 {
  uart1_putch(identify[fp_i]);
  fp_i++;
 }
 fp_j=0;
 while(fp_j==0);
 main_delay(500);       
   
 if(fp[9]==0x00)
 {
  ide=1;
  lcd_cmd(0x01);                                                
  lcd_puts(" successfully ");
  lcd_cmd(0xc0);                                                
  lcd_puts("identified  ");

  //lcd_puts1(0,4," successfully    ");
//lcd_puts1(0,5,"identified   ");
  id=fp[11];
  //lcd_puts1(0,5," ur id : ");
  //lcd_data2(fp[11]/10+48);
  //lcd_data2(fp[11]%10+48);

  lcd_data(fp[11]/10+48);
  lcd_data(fp[11]%10+48);
  main_delay(3000);       
 }
 else
 {
  lcd_cmd(0x01);                                                
  lcd_puts("IDENTIFY FAILED");
  //lcd_puts1(0,4,"IDENTIFY FAILED..");
 main_delay(3000);       

  goto end;
 }
 end:
 main_delay(1);
}

2.  gsm.h file 

#include "LCD.h" 


extern unsigned char mx,my,mz,mm;
unsigned char uc_temp,uc_temp1,uc_temp2=0;
unsigned long int uli_temp3=0; 


void gsm_delay( unsigned int value );
void gsm_cmd(char *cmd);
void gsm_check(void);
void gsm_init(void);
void gsm_send_num_mesg(unsigned char *num,unsigned char *mes);

unsigned char msg[50],mobilenum[11];

void gsm_delay( unsigned int value )
{
 unsigned int ui_temp1,ui_temp2;
 for(ui_temp1=0;ui_temp1<value;ui_temp1++)
 for(ui_temp2=0;ui_temp2<2500;ui_temp2++);
}

void gsm_cmd(char *cmd)
{
 while(*cmd)      
 {
  while (!(U0LSR & 0x20));
  U0THR = *cmd++;
 }   
}

void gsm_enter(void)
{
 uart0_putch(10);
 uart0_putch(13);         
}

void gsm_check()
{
 check:
 uc_temp1=0;
 uli_temp3=0;
 gsm_cmd("AT");
 gsm_enter();
 while(uc_temp1<10)
 {
  while (!(U0LSR & 0x01))
  {
   uli_temp3++;
   if(uli_temp3==6000000)
   {
    uli_temp3=0;
goto end;
   }
  }
  uc_temp= U0RBR;
  if(uc_temp=='O')
  {
   uc_temp=uart0_getch();
   if(uc_temp=='K')
   {
    uc_temp2=1;
    break;
   }
  }
  uc_temp1++ ;
  uli_temp3=0;
 }
 end:
 if(uc_temp2==0)
 {
  lcd_cmd(0x01);
 lcd_puts("MODEM IS NOT");
 lcd_cmd(0xc0);
 lcd_puts("        READY");
 gsm_delay(1000);
  goto check;
 }
}

void gsm_init()
{
 check1:
 uc_temp1=0;
 uli_temp3=0;
 uc_temp2=0;
 gsm_cmd("ATE0");
 gsm_enter();
 while(uc_temp1<10)
 {
  while (!(U0LSR & 0x01))
  {
   uli_temp3++;
   if(uli_temp3==8000000)
   {
    uli_temp3=0;
goto end1;
   }
  } // Wait RXD Receive Data Ready
  uc_temp= U0RBR;
  if(uc_temp=='O')
  {
   uc_temp=uart0_getch();
   if(uc_temp=='K')
   {
    uc_temp2=1;
    break;
   }
  }
  uc_temp1++ ;
  uli_temp3=0;
 }
 end1:
 if(uc_temp2==0)
 {
  lcd_cmd(0x01);
 lcd_puts("MODEM IS NOT");
 lcd_cmd(0xc0);
 lcd_puts("        READY");
 gsm_delay(1000);
  goto check1;
 }
  check:
 uc_temp1=0;
 uli_temp3=0;
 uc_temp2=0;
 gsm_cmd("AT+CMGF=1");
 gsm_enter();
 while(uc_temp1<10)
 {
  while (!(U0LSR & 0x01))
  {
   uli_temp3++;
   if(uli_temp3==8000000)
   {
    uli_temp3=0;
goto end;
   }
  } // Wait RXD Receive Data Ready
  uc_temp= U0RBR;
  if(uc_temp=='O')
  {
   uc_temp=uart0_getch();
   if(uc_temp=='K')
   {
    uc_temp2=1;
    break;
   }
  }
  uc_temp1++ ;
  uli_temp3=0;
 }
 end:
 if(uc_temp2==0)
 {
  
 lcd_cmd(0x01);
 lcd_puts("MODEM IS NOT");
 lcd_cmd(0xc0);
 lcd_puts("        READY");
 gsm_delay(1000);

  goto check;
 }

 lcd_cmd(0x01);
 lcd_puts("MODEM IS READY");
 gsm_delay(2000);
}

void gsm_clear_msg(char num)
{
 check:
 uc_temp1=0;
 uli_temp3=0;
 uc_temp2=0;
 gsm_cmd("at+cmgd=");
 uart0_putch(num+48);
 gsm_enter(); 
 while(uc_temp1<10)
 {
  while (!(U0LSR & 0x01))
  {
   uli_temp3++;
   if(uli_temp3==8000000)
   {
    uli_temp3=0;
    goto end;
   }
  } // Wait RXD Receive Data Ready
  uc_temp= U0RBR;
  if(uc_temp=='O')
  {
   uc_temp=uart0_getch();
   if(uc_temp=='K')
   uc_temp2=1;
   break;
  }
  uc_temp1++ ;
  uli_temp3=0;
  }
  end:
  if(uc_temp2==0)
  {
   lcd_cmd(0x01);
   lcd_puts("MSG DELETE ERROR");
   gsm_delay(1500);
   goto check;
  }
  lcd_cmd(0x01);
  lcd_puts("MSG DELETED");
  gsm_delay(2000);
}    


void gsm_send_num_mesg(unsigned char *num,unsigned char *mes)
{
 unsigned char uc_temp,uc_temp1,uc_temp3=0;
 unsigned long long int uli_temp2;
 U1IER=0;
 U0IER=0;
 gsm_cmd("at+cmgs=");
 uart0_putch('"');
 while(*num)
 uart0_putch(*num++);
 uart0_putch('"');
 gsm_enter();
 while(*mes)
 uart0_putch(*mes++);
 gsm_enter();

 gsm_enter();
 uart0_putch(0x1a);
 uc_temp1=0;
 uli_temp2=0;
 while(uc_temp1<10)
 {
  while (!(U0LSR & 0x01))
  {
   if(uli_temp2==8000000)
   {
    lcd_cmd(0x01);
    lcd_puts("MSG SENDING ");
    lcd_cmd(0xc0);
    lcd_puts("       ERROR");
    gsm_delay(2000);
lcd_cmd(0x01);
    lcd_puts("MODEM IS");
    lcd_cmd(0xc0);
    lcd_puts("   NOT CONNECTED");
    gsm_delay(2000);
goto end;
   }
   uli_temp2++;
  } // Wait RXD Receive Data Ready
  uc_temp= U0RBR;
  if(uc_temp=='+')
  {
   uc_temp=uart0_getch();
   if(uc_temp=='C')
   uc_temp=uart0_getch();
   else
   {
    lcd_cmd(0x01);
    lcd_puts("NO BALENCE");
    lcd_cmd(0xc0);
    lcd_puts("  IN UR SIM CARD");
    gsm_delay(2000);
goto end;
   }
   if(uc_temp=='M')
   uc_temp=uart0_getch();
   else
   {
    lcd_cmd(0x01);
    lcd_puts("NO BALENCE");
    lcd_cmd(0xc0);
    lcd_puts("  IN UR SIM CARD");
    gsm_delay(2000);
goto end;
   }
   if(uc_temp=='G')
   uc_temp=uart0_getch();
   else
   {
    lcd_cmd(0x01);
    lcd_puts("NO BALENCE");
    lcd_cmd(0xc0);
    lcd_puts("  IN UR SIM CARD");
    gsm_delay(2000);
goto end;
   }
   if(uc_temp=='S')
   {
    uc_temp3=1;
    break;
   }
   else
   {
    lcd_cmd(0x01);
    lcd_puts("NO BALENCE");
    lcd_cmd(0xc0);
    lcd_puts("  IN UR SIM CARD");
    gsm_delay(2000);
goto end;
   }
  }
  uc_temp1++ ;
 }
 if(uc_temp3==1)
 {
  lcd_cmd(0x01);
  lcd_puts("MESSAGE HAS BEEN");
  lcd_cmd(0xc0);
  lcd_puts("   SENT TO USER");
  gsm_delay(2000);
 }
 else
 {
  lcd_cmd(0x01);
  lcd_puts("MSG SENDING ");
  lcd_cmd(0xc0);
  lcd_puts("       ERROR");
  gsm_delay(2000);
 }
 end: 
 U1IER=0x01;
 U0IER=0x01;
}


void gsm_send_num_mesg_data(unsigned char *num,unsigned char *mes ,unsigned char *mes1)
{
 unsigned char uc_temp,uc_temp1,uc_temp3=0;
 unsigned long long int uli_temp2;
 U1IER=0;
 U0IER=0;
 gsm_cmd("at+cmgs=");
 uart0_putch('"');
 while(*num)
 uart0_putch(*num++);
 uart0_putch('"');
 gsm_enter();
 while(*mes)
 uart0_putch(*mes++);
 gsm_enter();
 while(*mes1)
 uart0_putch(*mes1++);
 gsm_enter();
 uart0_putch(0x1a);
 uc_temp1=0;
 uli_temp2=0;
 while(uc_temp1<10)
 {
  while (!(U0LSR & 0x01))
  {
   if(uli_temp2==8000000)
   {
    lcd_cmd(0x01);
    lcd_puts("MSG SENDING ");
    lcd_cmd(0xc0);
    lcd_puts("       ERROR");
    gsm_delay(2000);
lcd_cmd(0x01);
    lcd_puts("MODEM IS");
    lcd_cmd(0xc0);
    lcd_puts("   NOT CONNECTED");
    gsm_delay(2000);
goto end;
   }
   uli_temp2++;
  } // Wait RXD Receive Data Ready
  uc_temp= U0RBR;
  if(uc_temp=='+')
  {
   uc_temp=uart0_getch();
   if(uc_temp=='C')
   uc_temp=uart0_getch();
   else
   {
    lcd_cmd(0x01);
    lcd_puts("NO BALENCE");
    lcd_cmd(0xc0);
    lcd_puts("  IN UR SIM CARD");
    gsm_delay(2000);
goto end;
   }
   if(uc_temp=='M')
   uc_temp=uart0_getch();
   else
   {
    lcd_cmd(0x01);
    lcd_puts("NO BALENCE");
    lcd_cmd(0xc0);
    lcd_puts("  IN UR SIM CARD");
    gsm_delay(2000);
goto end;
   }
   if(uc_temp=='G')
   uc_temp=uart0_getch();
   else
   {
    lcd_cmd(0x01);
    lcd_puts("NO BALENCE");
    lcd_cmd(0xc0);
    lcd_puts("  IN UR SIM CARD");
    gsm_delay(2000);
goto end;
   }
   if(uc_temp=='S')
   {
    uc_temp3=1;
    break;
   }
   else
   {
    lcd_cmd(0x01);
    lcd_puts("NO BALENCE");
    lcd_cmd(0xc0);
    lcd_puts("  IN UR SIM CARD");
    gsm_delay(2000);
goto end;
   }
  }
  uc_temp1++ ;
 }
 if(uc_temp3==1)
 {
  lcd_cmd(0x01);
  lcd_puts("MESSAGE HAS BEEN");
  lcd_cmd(0xc0);
  lcd_puts("   SENT TO USER");
  gsm_delay(2000);
 }
 else
 {
  lcd_cmd(0x01);
  lcd_puts("MSG SENDING ");
  lcd_cmd(0xc0);
  lcd_puts("       ERROR");
  gsm_delay(2000);
 }
 end: 
 U1IER=0x01;
 U0IER=0x01;
}

void gsm_mes_read(void)         
{
 unsigned char a,b,i,count,numcnt;
 U1IER=0;
 U0IER=0;
 gsm_delay(100);

 while ((U0LSR & 0x01)) // Wait RXD Receive Data Ready
 {
  b= U0RBR;
  gsm_delay(5);
 }
   
 gsm_cmd("at+cmgr=1");
 gsm_enter();
 count=0;
 i=0;
 a=0;
 numcnt=0;

 while(count!=3)
 {
  b=uart0_getch();
  if((b==',')||(a==1))
  {
   if(numcnt<15)
   {
    if(numcnt>4)
    {
     mobilenum[numcnt-5]=b;
    }
    a=1;
    numcnt++;
   }
   else
   a=0;
  }
  if(count==2)
  {
   msg[i++]=b;
  }
  if(b==10)
  count+=1;
 }
 msg[--i]='\0';
 msg[--i]='\0';
 mobilenum[10]='\0';
 lcd_cmd(0x01);
 lcd_puts(msg);
 gsm_delay(2000);
 gsm_cmd("at+cmgd=1");
 gsm_enter();
 U1IER=0x01;
 U0IER=0x01;
}

3. lcd.h

//*****************************************************************************
// file name :lcd.h 
//*****************************************************************************

#ifndef _LPC214X_H_
#define _LPC214X_H_

// Define LCD PinIO Mask 
#define  LCD_RS     0x00010000   // P1.16(0000 0000 0000 000x 0000 0000 0000 0000)
#define  LCD_EN     0x00020000   // P1.17(0000 0000 0000 00x0 0000 0000 0000 0000)

#define  LCD_D4     0x00040000   // P1.18(0000 0000 0000 0x00 0000 0000 0000 0000)
#define  LCD_D5     0x00080000   // P1.19(0000 0000 0000 x000 0000 0000 0000 0000)
#define  LCD_D6     0x00100000   // P1.20(0000 0000 000x 0000 0000 0000 0000 0000)
#define  LCD_D7     0x00200000   // P1.21(0000 0000 00x0 0000 0000 0000 0000 0000)


lcd_cmd(unsigned char val)
{
 unsigned int lcd_ch;
 unsigned int lcd_i; // LCD Initial Delay Count 

 IOCLR1 = LCD_RS ; // RS = 0 

 lcd_ch=((val>>4)&0x0F); // Strobe 4-Bit High-Nibble to LCD

 IOCLR1 = (LCD_D7|LCD_D6|LCD_D5|LCD_D4); // Reset 4-Bit Pin Data
 IOSET1 = (lcd_ch<<18); // EN,0,RW,RS:DDDD:0000:0000:0000:0000:0000:0000   

 IOSET1 = LCD_EN ; // EN = 1 (Enable)
 for (lcd_i=0;lcd_i<10000;lcd_i++);
 IOCLR1 = LCD_EN ; // EN = 0 (Disable)
  
 lcd_ch=(val&0x0F);   // Strobe 4-Bit Low-Nibble to LCD

 IOCLR1 = (LCD_D7|LCD_D6|LCD_D5|LCD_D4);   // Reset 4-Bit Pin Data
 IOSET1 = (lcd_ch<<18); // EN,0,RW,RS:DDDD:0000:0000:0000:0000:0000:0000   

 IOSET1 = LCD_EN ; // EN = 1 (Enable)
 for (lcd_i=0;lcd_i<10000;lcd_i++);
 IOCLR1 = LCD_EN ; // EN = 0 (Disable)
  
 for (lcd_i=0;lcd_i<10000;lcd_i++);
}

lcd_data(unsigned char val)
{
 unsigned int lcd_ch;
 unsigned int lcd_i; // LCD Initial Delay Count 

 IOSET1 = LCD_RS ; // RS = 1 

 lcd_ch=((val>>4)&0x0F); // Strobe 4-Bit High-Nibble to LCD

 IOCLR1 = (LCD_D7|LCD_D6|LCD_D5|LCD_D4);   // Reset 4-Bit Pin Data
 IOSET1 = (lcd_ch<<18); // EN,0,RW,RS:DDDD:0000:0000:0000:0000:0000:0000   

 IOSET1 = LCD_EN ; // EN = 1 (Enable)
 for (lcd_i=0;lcd_i<10000;lcd_i++);
 IOCLR1 = LCD_EN ; // EN = 0 (Disable)
  
 lcd_ch=(val&0x0F);   // Strobe 4-Bit Low-Nibble to LCD

 IOCLR1 = (LCD_D7|LCD_D6|LCD_D5|LCD_D4);   // Reset 4-Bit Pin Data
 IOSET1 = (lcd_ch<<18); // EN,0,RW,RS:DDDD:0000:0000:0000:0000:0000:0000   

 IOSET1 = LCD_EN ; // EN = 1 (Enable)
 for (lcd_i=0;lcd_i<10000;lcd_i++);
 IOCLR1 = LCD_EN ; // EN = 0 (Disable)
  
 for (lcd_i=0;lcd_i<10000;lcd_i++);
}

void lcd_puts(unsigned char* str)
{
 while(*str)
 lcd_data(*str++);
}

void lcd_int(unsigned int lcd_value)
{
 unsigned int lcd_arr[10],lcd_val;

 for(lcd_val=1;lcd_val<5;lcd_val++)
 {
  lcd_arr[lcd_val] = lcd_value%10;
  lcd_value  = lcd_value/10;
 }

 for(lcd_val=4; lcd_val!=0 ; lcd_val--) //sending data to LCD
 {
  lcd_data(lcd_arr[lcd_val]+48);
 }
}


lcd_init()
{
 unsigned int lcd_main_i; // LCD Initial Delay Count 

 PINSEL2 |= 0x00000000; // GPIO1[31..26] = I/O Function
 IODIR1  |= 0x003F0000 ; // LCD Data Bus = Write // LCD Data Bus = Write
 for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++); // Power-On Delay (15 mS)

 IOCLR1 = ((LCD_D7|LCD_D6|LCD_D5|LCD_D4|LCD_RS|LCD_EN)); // Reset (RS,RW,EN,4-Bit Data) Pin
 IOSET1 = (LCD_D5|LCD_D4); // DDDD:EN,RW,RS,0:0000:0000:0000:0000:0000:0000 
 IOSET1 = LCD_EN ; // EN = 1 (Enable)
 for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++);
 IOCLR1 = LCD_EN ; // EN = 0 (Disable)
 for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++); // Delay 4.1mS

 IOCLR1 = ((LCD_D7|LCD_D6|LCD_D5|LCD_D4|LCD_RS|LCD_EN));   // Reset (RS,RW,EN,4-Bit Data) Pin
 IOSET1 = (LCD_D5|LCD_D4); // DDDD:EN,RW,RS,0:0000:0000:0000:0000:0000:0000 
 IOSET1 = LCD_EN ; // EN = 1 (Enable)
 for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++);
 IOCLR1 = LCD_EN ; // EN = 0 (Disable)
 for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++); // delay 100uS
  
 IOCLR1 = ((LCD_D7|LCD_D6|LCD_D5|LCD_D4|LCD_RS|LCD_EN));   // Reset (RS,RW,EN,4-Bit Data) Pin
 IOSET1 = (LCD_D5|LCD_D4); // DDDD:EN,RW,RS,0:0000:0000:0000:0000:0000:0000 
 IOSET1 = LCD_EN ; // EN = 1 (Enable)
 for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++);
 IOCLR1 = LCD_EN ; // EN = 0 (Disable)
 for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++);  

 IOCLR1 = ((LCD_D7|LCD_D6|LCD_D5|LCD_D4|LCD_RS|LCD_EN));   // Reset (RS,RW,EN,4-Bit Data) Pin
 IOSET1 = (LCD_D5); // DDDD:EN,RW,RS,0:0000:0000:0000:0000:0000:0000 
 IOSET1 = LCD_EN ; // EN = 1 (Enable)
 for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++);
 IOCLR1 = LCD_EN ; // EN = 0 (Disable)
 for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++);
 
 lcd_cmd(0x28);  
 lcd_cmd(0x0c); 
 lcd_cmd(0x06); 
 lcd_cmd(0x01);
 for (lcd_main_i=0;lcd_main_i<10000;lcd_main_i++); // Wait Command Ready
}

void lcd_float(float value)
{
   unsigned char xxx[5],z=0;
   int intval;
   

   intval=(int)value;

   value=value-intval;

   while(intval!=0)
   {
    xxx[z]=intval%10;
intval=intval/10;
    z++;
    }
while(z!=0)
{
z--;

   lcd_data(xxx[z]+48);
   }
   lcd_puts(".");
   
   intval=value*10;
    lcd_data(intval+48);
  /* while(intval!=0)
   {
    xx[z]=intval%10;
intval=intval/10;
    z++;
}
while(z!=0)
{
z--;
lcd_data(xx[z]+48);
} */
 }


#endif


4. uart.h

void uart0_init()
{
 PINSEL0 |=0x00000005;

 U0LCR =0X80;
 U0DLL =97;
 U0LCR =0X03;
}

void com_baudrate0 (unsigned int baudrate) 
{
  unsigned long DLreload;

  PINSEL0 |=0x00000005;
  DLreload = (15000000UL / baudrate) / 16UL;

  U0LCR = 0x80;           /* Set DLAB */
  U0DLL = DLreload;
  U0DLM = (DLreload >> 8);
  
  U0LCR = 0x03;          /* Clear DLAB */
}

void uart0_putch(unsigned char val)
{
 while(!(U0LSR & 0x20));
 U0THR =val;


unsigned char uart0_getch()
{
 while(!(U0LSR & 0x01));
 return(U0RBR);
}

void uart0_puts( char *stringptr)
{
  while (*stringptr)
   uart0_putch(*stringptr++);


void uart0_int(unsigned long value)
{
 unsigned char arr[10];
 unsigned char val=0;
 if(value==0)
 uart0_putch(0+48);

 while(value!=0)
 {
  arr[val] = value%10;
  value  = value/10;
  val++;
 }

 while(val!=0)
 {
  val--;
  uart0_putch(arr[val]+48);
 }
}

  

5. uart1.h 



       void uart1_init()
{
 PINSEL0 |=0x00050000;
 U1LCR =0X80;
 U1DLL =97;
 U1LCR =0X03;
}

void uart1_putch(unsigned char val)
{
 while(!(U1LSR & 0x20));
 U1THR =val;

unsigned char uart1_getch()
{
 while(!(U1LSR & 0x01));
 return(U1RBR);

void uart1_puts( unsigned char *stringptr)
{
  while (*stringptr)
   uart1_putch(*stringptr++);

void uart1_int(unsigned long value)
{
 unsigned char arr[10];
 unsigned char val=0;
 if(value==0)
 uart1_putch(0+48);

 while(value!=0)
 {
  arr[val] = value%10;
  value  = value/10;
  val++;
 }

 while(val!=0)
 {
  val--;
  uart1_putch(arr[val]+48);
 }
}