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 / facing problem in serial port programming

facing problem in serial port programming

|

Microcontroller › 8051 › facing problem in serial port programming

  • This topic has 0 replies, 1 voice, and was last updated 9 years, 10 months ago by Shashiraj Shettyan M.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • March 21, 2016 at 10:02 am #4384
    Shashiraj Shettyan M
    Participant

    Hello everyone,

        I am trying to make "voice based home appliance control using microcontroller". I am using geetech voice recognition module and connected it to microcontroller through serial port (P3.0 & P3.1). I have loaded 5 voices into the voice recognition module. I have written the code also. But I am not able to get the output. I connected LED's at the output pins. I think there is something wrong in code. Please, can anyone rectify?

    My code is,

    #include <p89v51rx2.h>
    #include<string.h>
    sbit fan=P1^0;
    sbit wrg=P1^1;
    void delay(unsigned int it)
    {
    unsigned int i,j;
    for(i=0;i<=it;i++);
    for(j=0;j<1275;j++);
    }
    void init_serial()
    {
    SCON=0x50;
    delay(2000);
    TMOD=0x20;
    delay(2000);
    TH1=0xFD;
    delay(2000);
    TR1=1;
    delay(1000);
    }
    unsigned char rec()
    {
    unsigned char a;
    while(RI==0);
    a=SBUF;
        delay(1000);
    RI=0;
    delay(1000);
    return a;
    }
    void main()
    {
      unsigned char cmd;
      fan=0;
      wrg=0;
      while(1)
      {
        init_serial();
        delay(20000);
        cmd=rec();
    delay(20000);
    switch(cmd)
    {
     case 0x11: fan=1;                //command 1
                break;
     case 0x12: wrg=1; //command 2
                break;
     case 0x13: fan=1;                //command 3
                break;
     case 0x14: wrg=1; //command 4
                break;
     case 0x15: fan=1; //command 4
                break;
    }
      }
    }
  • Author
    Posts
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • FM Radio circuits February 7, 2026
  • wall transformer polarity February 7, 2026
  • To buy or DIY? February 7, 2026
  • engineering analysis of shmidth trigger without simulation February 6, 2026
  • ANOTHER OLD PROJECT REDO February 6, 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