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 / It work fine but lettle

It work fine but lettle

|

Microcontroller › 8051 › Cannot Receive 4digit Integer value from serial port › It work fine but lettle

December 18, 2014 at 4:11 pm #12431
Bakhtiar
Participant

It work fine but lettle problem i faceing, this is

the define string compare is ok for string compare but if i again press the same keys the
it will take only first digit for example

#include<reg51.h>
#include<string.h>
#define dataport P2
int  i=0;
unsigned char msg[20];
void lcdcmd(unsigned char);
void lcddata(unsigned char);

void compare()
{

if(strcmp(msg,”1234″)==0)
{
     
     lcdcmd(0x01);
     lcddata(‘B’);
    
     i=0;
    
   }
 if (strcmp(msg,”4321″)==0)
{

 
     lcdcmd(0x01);
     lcddata(‘C’);
    
     i=0;
        }
}

void recieve() interrupt 4
{

while (RI != 1) {;}

msg[i++] = SBUF;
    RI = 0;

        compare();
    
         
 }

void main()
{
while(1);
}
void lcdcmd(unsigned char value)
{   dataport=value;
      rs=0;
      rw=0;
      en=0;
      delay(1);
      en=1;
}

void lcddata(unsigned char value2)
{  dataport=value2;
      rs=1;
      rw=0;
      en=0;
      delay(1);
      en=1;
}

if again press “1” then the first compare block will display ‘B’ it will
not take “234”
but if i press another digit block that is “4321” it will take that one and display ‘C’
 again if i press first 4 digit then
it will display ‘B’

it will still not empty the fist digit block
but take second digit block again it will take first digit block so on.

RSS Recent Posts

  • mechanism to shutdown feeding when sensor temperature rises December 9, 2025
  • Want Thermal Camera with Fixed Thermal Span option December 8, 2025
  • Bad design , bad maintenance or just how it was. December 8, 2025
  • Looking for single photovoltaic cells for light gate December 8, 2025
  • Sanity Check – Peltier "Cooler" for Heating and Cooling December 8, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 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