The code below takes in values from LDR but only one LEDis lit. The other 3 LEDs are always off. What can I do to correctthis ?
#include \"mbed.h\"
AnalogIn ADC(A5);
BusOut myLEDs(D10, D11, D12, D13); //Using Bus out instead ofDigitalOut for Group of signals in order to control multipleoutputs Â
PwmOut Led1(D10);
PwmOut Led2(D11);
PwmOut Led3(D12);
PwmOut Led4(D13);
 Â
 Â
int main(void)
 Â
{
   while(1)
   {
       float brightness;
     //LEDs.period(1);
       brightness=1-ADC.read();
       float I_val;
        I_val=brightness*100;//Intensity value= I_val
        printf(\"lightLevel =%3.1f%%\n\", I_val);//maximum of 5 significant figures andmaximum of 2 decimal places.
       wait(1);
    Â
   Led1.period(1.0f);//period to be 1second Â
   Led2.period(1.0f);
   Led3.period(1.0f);
   Led4.period(1.0f);
    Â
    Â
    Â
   if(I_val<25)
    Â
   {
       Led1.write(0.0f);//duty cycle as 20% of 1 period (1 second)
       Led2.write(0.0f);
       Led3.write(0.0f);
       Led4.write(0.0f);
       break;
   } Â
   else if(I_val >=25 && I_val<50)
    Â
   {
       Led1.write(0.25f);
       Led2.write(0.25f);
       Led3.write(0.25f);
       Led4.write(0.25f);       Â
       break;
   }
    Â
   else if(I_val >=50 && I_val<75)
   {
      Â
       Led1.write(0.50f);
       Led2.write(0.50f);
       Led3.write(0.50f);
       Led4.write(0.50f);
       break;
   }
    Â
   else if (I_val >=75 &&I_val<100)
    Â
   {
        Â
       Led1.write(0.75f);
       Led2.write(0.75f);
       Led3.write(0.75f);
       Led4.write(0.75f);
       break;
   }
    Â
   else if (I_val ==100)   Â
   {      Â
       Led1.write(1);
       Led2.write(1);
       Led3.write(1);
       Led4.write(1);
       break;
   }
   else if (I_val<0 && I_val>100)
   {
        printf(\"ERROR!\");
   }
   }
    Â
    Â
}
The task is to use mbed library with  Nucleo64 bits STM32f303RE ARM board and the four redleds as lighting devices. There are five required levelsof lighting, 1, 2, 3, 4 and off. The lighting level is controlledby the lightness/darkness detected by the LDR sensor, for examplewhen it is very light, all the leds will be off, and when it isvery dark all the four leds will be on. All the 5 levels oflighting will be corresponded to the evenly distributed ‘ReadIn’value from the LDR. PWM control is not required for this task.
That is, Â
[1.] when the darkness corresponding to 25% then one ofthe 4 led will be lit with 25% of duty cycleand Â
[2.] when darkness is equivalent to 50% then the 2 of 4LEDs will be lit with 50% duty cycle and  Â
[3.] when when darkness corresponds 75% then3 of 4 LEDs will be lit with 75% duty cycle and  Â
[4.] with complete darkness all the 4 LEDs withbe lit with 100% duty cycle of brightness