- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Labels:
-
PSoC Creator Software
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Yohann,
In my opinion, you can add a global variable as a flag and initial it as 0. In the loop, green LED turned on once, set the flag as 1, if the flag not 0, not turn on green LED any more.
Kindly let me know if I misunderstood your question.
Thanks,
Ryan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Yohann,
In my opinion, you can add a global variable as a flag and initial it as 0. In the loop, green LED turned on once, set the flag as 1, if the flag not 0, not turn on green LED any more.
Kindly let me know if I misunderstood your question.
Thanks,
Ryan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if i understood what you said i need create an other void function to stop the led ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes. I'm afraid more code is must.
You can use a Timer component. Refer more code examples in PSoC Creator.
Thanks,
Ryan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I use a flag and my led work. Thank you for your help.