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 / Topics / Home automation using android

Home automation using android

|

Microcontroller › 8051 › Home automation using android

  • This topic has 1 reply, 2 voices, and was last updated 12 years, 2 months ago by SHAH DISHANT H..
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • March 11, 2014 at 2:08 pm #2942
    mrutyunjay parida
    Participant

    This is the code but it wasn’t working perfectly.

    could anyone help me to correct it

     

    #include<at89x52.h> 
    #include<intrins.h> 
    sbit LAMP1=P2^0;
    sbit LAMP2=P2^1; 
    sbit LAMP3=P2^2; 
    sbit LAMP4=P2^3; 
    unsigned char ch; 
    void init_Serial()
    { 
    TMOD=0x10; 
    TH1=0xFA; 
    SCON=0x50; 
    TR0=1; 
    } 
    void Rx_Char() 
    { 
    while(RI=0); 
    ch=SBUF; 
    RI=1; 
    } 
    void Tx_String(unsigned char *str) 
    { 
    while(*str!=’’)
    {
    SBUF=*str;
    while(TI==0);
    TI=1;
    str++;
    }
    }
     
    void main()
    {
    P2=0XFF;
    init_Serial();
    Tx_String(“rENTER:r1:LAMP1 ONr3:LAMP2 ONr5:LAMP3 ONr7:LAMP4 ONr”);
    Tx_String(“rENTER:r2:LAMP1 OFFr4:LAMP2 OFFr6:LAMP3 OFFr8:LAMP4 OFFr”);
    Tx_String(“rENTER:r9:ALL LAMPS ONr”);
    Tx_String(“rENTER:r0:ALL LAMPS OFFr”);
     
    while(1)
    {
    Rx_Char();
    switch(ch)
    {
    case ‘1’:Tx_String(“rLAMP1 ONr”);
    LAMP1=1;
    break;
    case ‘2’:Tx_String(“LAMP1 OFFr”);
    LAMP1=0;
    break;
    case ‘3’:Tx_String(“LAMP2 ONr”);
    LAMP2=1;
    break;
    case ‘4’:Tx_String(“LAMP2 OFFr”);
    LAMP2=0;
    break;
    case ‘5’:Tx_String(“LAMP3 ONr”);
    LAMP3=1;
    break;
    case ‘6’:Tx_String(“LAMP3 OFFr”);
    LAMP3=0;
    break;
    case ‘7’:Tx_String(“LAMP4 ONr”);
    LAMP4=1;
    break;
    case ‘8’:Tx_String(“LAMP4 OFFr”);
    LAMP4=0;
    break;
    case ‘9’:Tx_String(“ALL LAMPS ONr”);
    LAMP1=1;
    LAMP2=1;
    LAMP3=1;
    LAMP4=1;
    break;
    case ‘0’:Tx_String(“ALL LAMPS OFFr”);
    LAMP1=0;
    LAMP2=0;
    LAMP3=0;
    LAMP4=0;
    break;
    default :LAMP1=1;
    LAMP2=1;
    LAMP3=1;
    LAMP4=1;
    break;
    }
    }
    }
     
     
     
    March 12, 2014 at 3:21 am #11287
    SHAH DISHANT H.
    Participant

    Hi,

     

    You have not received any command. So it will not work.

     

    Try this.

    ch=Rx_Char();

    switch (ch)

     

    This will work for sure

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Projector focus circuit May 18, 2026
  • Relay question May 18, 2026
  • Phone Charger 5v to 12v May 17, 2026
  • reviving old swordfish program but? May 17, 2026
  • Assistance locating a 'trail' camera gadget, please ? 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