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 / Hi Usman,I’ve once faced the

Hi Usman,I’ve once faced the

|

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.
 

RSS Recent Posts

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 Arrowfly 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 Arrowfly
Privacy Policy | Advertising

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