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
  • Advertise
You are here: Home / Replies / sir can you give me coding

sir can you give me coding

|

Microcontroller › AVR › gsm based water pump controller using atmega16 › sir can you give me coding

May 27, 2013 at 5:38 am #9827
Shashank Rao.C
Participant

sir can you give me coding for that? i am very very new to embedde c.

 i got similar coding from efy. i did some changes. but it is for 8051. i am confused that how to covert that for atmega16 please help me…

coding is as bellow. i am unable to understand that how it works. means how mcu will know that msg has been recived, what it tells and how it will take action….

 

 

#include<reg51.h>
sbit rs=P3^7;
sbit rw=P3^6;
sbit e=P3^5;
sbit pump=P1^0;
void gsmcmdsend(unsigned char *cmd);
void cmm(char value);
void dat(char value);
void compare();
unsigned char card_id[96];
unsigned char header[]=”SRC”;
unsigned char gsm_cmd3[]=”AT&W”;
unsigned char gsm_cmd4[]=”AT+CMGF”;
void gsmcmdsend(unsigned char *cmd)        
{
    unsigned char i;
    for(i=0;*cmd!=’’;i++)
    {
        SBUF=*cmd;
           while(TI==0);
        TI=0;
        cmd++;
        }
        SBUF=0x0A;
        while(TI==0);
        TI=0;
        SBUF=0x0D;
        while(TI==0);
        TI=0;
        while(RI==0);
        RI=0;
}
void delay(int count)    //Function to provide delay
{
    int i,j;
    for(i=0;i<count;i++)
    for(j=0;j<1275;j++);
}
void cmm(char value)
{
    P2 = value;
    rs=0;
    rw=0;
    e=1;
    delay(1);
    e=0;
    delay(1);
    return;
}
void dat(char value)
{
    P2 =value;
    rs=1;
    rw=0;
    e=1;
    delay(1);
    e=0;
    delay(1);
    return;
}
void lcdin()
{    cmm(0x38);
    cmm(0x0e);
    cmm(0x01);
    cmm(0x06);
    cmm(0x85);
    return;
}
void recieve()     //Function to recieve data serialy from RS232  
{
    unsigned char k;
     for(k=0;k<=87;k++)
     {  
         while(RI==0);  
          card_id[k]=SBUF;
          RI=0;
    }
}
void main()
{
    int l,i;
    P1=0x00;
    lcdin();
    TMOD=0x20;            //Enable Timer 1
    TH1=0XFD;
    SCON=0x50;
    TR1=1;
gsmcmdsend(gsm_cmd3);
cmm(0x01);
gsmcmdsend(gsm_cmd4);
cmm(0x01);
cmm(0x85);
for(i=0;i<3;i++)
    {dat(header);}
    cmm(0xc0);
while(1)
       {
         recieve();
         for(l=83;l<=87;l++)
         {  
              dat(card_id[l]);
         }          
         compare();
    }
}
void compare()
{                                                    
if ((card_id[83]==’p’)&&(card_id[84]==’u’) && (card_id[85]==’m’) && (card_id[86]==’p’) && (card_id[87]==’o’)&&(card_id[88]==’n’))
    pump=1;
else if((card_id[83]==’p’)&&(card_id[84]==’u’) && (card_id[85]==’m’) && (card_id[86]==’p’) && (card_id[87]==’o’)&&(card_id[88]==’f’))  
    pump=0;
;
}
 
end;                        //end of program 

RSS Recent Posts

  • Assistance locating a 'trail' camera gadget, please ? May 16, 2026
  • reviving old swordfish program but? May 16, 2026
  • Analog multiplexer has gone obselete May 16, 2026
  • Difference between TTL, RS232 and RS485 May 16, 2026
  • Smart Buoy project May 16, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 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
  • Advertise