This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LED not working as programmed

I created a program to glow LED once a flag is set. And until a switch is pressed, the LED should continue to glow. The switch is in pull up mode. But the LED is not glowing at all. Please guide.

       while(1)
             {
            // Inside indefinite loop, another function sets a flag
            switch(flag)
             {
               case 0:
               Glow_RedLED();
               break;

               case 1:
               Glow_GreenLED();
               break;
             }
            //While Loop ends here
              }


The Glow_GreenLED() is as below:


             void Glow_GreenLED()
              {
                LPC_PINCON->PINSEL4 &= ~((1<<26) | (1<<27));
                LPC_GPIO2->FIODIR|= (1<<13);
                LPC_PINCON->PINMODE4 &= ~((1<<26) | (1<<27));
                LPC_GPIO2->FIOSET = (1<<13);
              }

The Glow_RedLED() is as below:


              void Glow_RedLED()
              {
                LPC_PINCON->PINSEL4 &= ~((1<<16) | (1<<17));
                LPC_GPIO2->FIODIR|= (1<<8);
                LPC_PINCON->PINMODE4 &= ~((1<<16) | (1<<17));
                LPC_GPIO2->FIOSET = (1<<8);
              }