Microcontroller › PIC › Led number display › Hi Usman,I’ve once faced the
May 22, 2013 at 5:12 pm
#9811
AJISH ALFRED
Participant
Hi Usman,
I’ve once faced the same issue with the nested if-else. The problem got fixed by adding ‘else’ for evry ‘if’.
When there is an ‘if’ there should be an ‘else’ eventhough there is nothing in the ‘else’ statement.
Coming to your code, the last ‘else-if’ condition is not terminated with an ‘else’.
Suggest you to add an ‘else’ like the following;
if ((led1==1 || led2 && led3 == 0)==1)
{
for(z=0; z<12; z++)
{
ldata=message1[z];
rs=1;
rw=0;
en=1;
MsDelay(1);
en=0;
}
}
else if (led2==1)
{
for(z=0; z<12; z++)
{
ldata=message2[z];
rs=1;
rw=0;
en=1;
MsDelay(1);
en=0;
}
}
else if(led3==1)
{
for(z=0; z<12; z++)
{
ldata=message3[z];
rs=1;
rw=0;
en=1;
MsDelay(1);
en=0;
}
}
else if(led1==0 && led2==0 && led3==0)
{
for(z=0; z<14; z++)
{
ldata=message4[z];
rs=1;
rw=0;
en=1;
MsDelay(1);
en=0;
}
} else; // HERE //
Please try and update the result.