Microcontroller › 8051 › Cannot Receive 4digit Integer value from serial port › It work fine but lettle
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.