Forum Replies Created
-
AuthorPosts
-
December 24, 2014 at 11:13 am in reply to: Cannot Receive 4digit Integer value from serial port #12455BakhtiarParticipant
Thanks your valuable answer.
Please ,
Can you tell how can i do this or any example. Then it will be very helpfull for me.
Thanks
December 22, 2014 at 5:36 pm in reply to: Cannot Receive 4digit Integer value from serial port #12445BakhtiarParticipantstill it will take the first block value ,i mean the array value is not empty.
if i press another block of value then previous array value will empty.
for example
first time
when press “1234” then lcd display
if i again press only “1” of that block that time also lcd display.But i want if i again press “1234” second time then lcd will display.
after your advice i change my code in below way.
void compare()
{if(strcmp(msg,”1234″)==0)
{
lcdcmd(0x01);
lcddata(‘B’);
i=0;
}
else if (strcmp(msg,”4321″)==0)
{
lcdcmd(0x01);
lcddata(‘C’);
i=0;
}
}void recieve() interrupt 4
{while (RI != 1) {;}
msg[i++] = SBUF;
RI = 0;compare();
}but still face problem
December 18, 2014 at 4:11 pm in reply to: Cannot Receive 4digit Integer value from serial port #12431BakhtiarParticipantIt 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.December 12, 2014 at 1:23 pm in reply to: Cannot Receive 4digit Integer value from serial port #12419BakhtiarParticipantThanks a lot sir,
Your instruction is finally give me solution.I have appled and its done successfull.
I reset the “i” and it worked.
Thanks again Sir.
December 10, 2014 at 9:17 am in reply to: Cannot Receive 4digit Integer value from serial port #12408BakhtiarParticipantThanks a lot about your reply.
Ok if i use array then my program is receive using serial first time data here is my code.
void compare()
{if(strcmp(msg,”1234″)==0)
{
lcdcmd(0x01);
lcddata(‘B’);
}
if (strcmp(msg,”4321″)==0)
{
lcdcmd(0x01);
lcddata(‘C’);
}
}void recieve() interrupt 4
{int i;
while (RI != 1) {;}msg[i++] = SBUF;
RI = 0;compare();
}for example: after running the code it take any one of the input
if input “1234”
then it worked.
but at the same time when i input
“4321”
it will not take.
please help me
-
AuthorPosts