EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
You are here: Home / Replies /  hello guys i am facing a

 hello guys i am facing a

|

Projects › Projects › vehicle tracking system using gsm and gps module ›  hello guys i am facing a

April 1, 2012 at 7:17 am #7375
neha sharma
Participant

 

hello guys i am facing a problem in sending sms…..
 
my developed code is here…plz check it out..
 
thanxx in advance…!!!!
 
 
 
 
 
 
 
 
 
#include<reg52.h>
#define lcd_data P2
#define lcd_cont() ((lcd_en=1),(delay(3)),(lcd_en=0))
void UART_init();
void send_to_modem(char*);
void enter();
void send(char);
void ch_send_to_modem(char*);
void lcd_init(void);    
void lcdcmd(unsigned char value);
void lcddata(unsigned char value);
void msgdisplay(unsigned char b[]);
void delay(unsigned int value);
void send_to_modem(char*);
void enter();
void send(char);
void ch_send_to_modem(char*);
unsigned char str[10],mobilenum[11]={“09887081656”};
 
                           
unsigned char mobilenum1[10];
code unsigned char str1[]={“OK”};
unsigned char l,s,n,a,b,i,count,j,jjj,hb=68;
sbit temp=P1^3;
sbit  lcd_rs   =  P1^0;
sbit  lcd_en   =  P1^2;
 
void main()
{
temp=1;
 lcd_init();
 UART_init();
 lcdcmd(0x84);
 msgdisplay(” welcome ” );
 delay(1000);
 
 
   
 lcdcmd(0x01);   
 msgdisplay(“searching for”);
 lcdcmd(0xc0);
 msgdisplay(“GSM modem”);
 delay(100); 
 send_to_modem(“ate0”);   //to avoid echo signals,
  enter();
   send_to_modem(“at”);
   enter();  // TO CHECKING GSM MODEM…
   send_to_modem(“at”);
   enter();
   send_to_modem(“at”);
   enter();
   send_to_modem(“at”);
   enter();
   send_to_modem(“atr”);
   enter();
   for(mobilenum=0;mobilenum<11;i++);
   for(s=0;s<5;s++)  // Here we are waiting for data whitch is sending by GSM modem  
   {  // to checking wether  the GSM modem  connected to system or
    while(RI==0);  // not.
    str=SBUF;
    RI=0;
   } 
 
      /* str=’’; 
    lcdcmd(0x01); 
    msgdisplay1(str);
    long_delay();
    n=strcmp(str3,str1); 
 
  if(n)
   goto again;  // GSM modem if those are matching then following messages 
  else 
   {*/  // are displaying on LCD.
     lcdcmd(0x01);
     msgdisplay(“SYSTEM”);
     lcdcmd(0xc3); 
     msgdisplay(“CONNECTED”);
     
//   } 
 
   send_to_modem(“at+cmgf=1”);
   enter();
   send_to_modem(“at+cmgd=1”);
   enter();
   send_to_modem(“at+cmgd=2”);
   enter();
   send_to_modem(“at+cmgd=3”);
   enter();
   send_to_modem(“at+cfcs=”);
   enter();
   send_to_modem(“gsm”);
   enter();
   RI=0;
    
    lcdcmd(0x01);
    msgdisplay(mobilenum);
 
  
  
  st:delay(2500);
 
while(RI==1)
{
 RI=0;
 delay(100);
 }
     
     lcdcmd(0x01);
     msgdisplay(“massage “);
     lcdcmd(0xc0); 
     msgdisplay(“start……”);
     
     while(RI==1);
   
 
   
   while(1)
    {
 
  if(temp==0)
       {
    resend:
lcdcmd(0x01);
         msgdisplay(“over temp”);
         lcdcmd(0xc3); 
         msgdisplay(“sending msg”);
         send_to_modem(“at+cmgs=+918233598587”);
lcdcmd(0x01);
msgdisplay(“No. sended”);
lcdcmd(0xc0);
msgdisplay(“sending msg….”);
    delay(10);
    enter();
    send_to_modem(“abnormal temerature from room1 “);
    ch_send_to_modem(0x1a);
    enter();
  while(RI==0);
    a=SBUF;
      RI=0;
  while(RI==0);
    b=SBUF;
      RI=0;
 
if(a==13)
 {
      lcdcmd(0x01);
           msgdisplay(“message sent “);
       goto st;
     }
      else
    {
 delay(2000);
 goto resend;
}
 }
 
       
 
 
}
}
 
 
 void lcd_init(void)
{
 lcdcmd(0x02);
 lcdcmd(0x02);
 lcdcmd(0x02);
 lcdcmd(0x28);
 lcdcmd(0x28);
 lcdcmd(0x28);
 lcdcmd(0x0c);
 lcdcmd(0x06);
 lcdcmd(0x01);
}
void lcdcmd(unsigned char value)   // LCD COMMAND
  {
      lcd_data=value&(0xf0);
      lcd_rs=0;
      lcd_cont();
      lcd_data=((value<<4)&(0xf0));
      lcd_rs=0;
      lcd_cont();
 }
 
                                          
void lcddata(unsigned char value)
  {  
     lcd_data=value&(0xf0);
     lcd_rs=1;
     lcd_cont();
     delay(3);
     lcd_data=((value<<4)&(0xf0));
     lcd_rs=1;
     lcd_cont();
     delay(3);
  }  
void msgdisplay(unsigned char b[])
  {
unsigned char s,count=0;
for(s=0;b!=’’;s++)
 {
  lcddata(b);
 }
}
void delay(unsigned int value)
 {
   unsigned int x,y;
   for(x=0;x<100;x++)
   for(y=0;y<value;y++);
 }
 
void UART_init()
{
  SCON = 0x50;
  TMOD = 0x20;
  TH1  = 0xFD;
  TR1  = 1;
}
 
void send_to_modem(char*s)
{
   while(*s != ‘’)
   {
     send(*s);
     s++;
   }
}
 
void ch_send_to_modem(char*s)
{
   while(*s != ‘’)
   {
     send(*s);
     s++;
   }
   send(‘r’);
   send(‘n’);
}
void send(char x)
{
  while(!TI);
  TI = 0;
  SBUF=x;
}
void enter()
{
 
  send(‘r’);
  send(‘n’);
}
 

RSS Recent Posts

  • Seeking Help to compile code August 17, 2022
  • Nokia 5110 HW in Oshonsoft August 17, 2022
  • Digital Display Information August 17, 2022
  • 2nd pcb design program? August 17, 2022
  • Door exit button August 17, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools