4 Replies Latest reply on Apr 17, 2018 12:50 AM by YohannEslan

    How can I switch off a led in a loop function ?

    YohannEslan

      Hi everyone !

       

      i haven't good skills in programmation and i have a question. I work with an Opamp and i want to turn off a Red led when my voltage > 3.0V and turn off when voltage < 3.0V. I am good with that, but i also want to turn on a Green led, during 2sec,  when the voltage < 3.0V. Only one time. If the voltage become higher than 3.0V  and become one more time lower than 3.0V, i just want 2sec of GreenLed and stop.

       

      I'm in a loop and its a problem

       

      if (Vout_tension > 3.0)

                  {

                      RED_Led_Write(~RED_Led_Read());

                      CyDelay(500);

                      GREEN_Led_Write(0);

                  }

              else

                  {

                      RED_Led_Write(0);

                      GREEN_Led_Write(1);

                      CyDelay(2000);

                      GREEN_Led_Write(0)

                  }

       

      GREEN_Led is always turn on when Vout_tension < 3.0, because im in a loop. Someone can help me to switch off the led after 2sec ?

       

      Thank you for help, and I'm very sorry about my bad english.

      Yohann