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

  • Voltage comparator circuit verification April 10, 2026
  • Help with a coffee machine circuitboard April 10, 2026
  • DS3231 RTC + 24C32 EEPROM I²C Module (PIC18) April 9, 2026
  • Bot checks April 9, 2026
  • Heltec V3 GPS repeater. April 9, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

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