How to turn of a LED?

Hi! :smiley:
I've got a little problem, let me tell you.

I'm new programming so I came out with this situation

I want to use a POT to determine the seconds LED1 and LED2 are going to be on.

When I push and keep pushing a BUTTON1, LED1 is going to turn on the time I set using the POT then once the time is over LED1 turns off (The button is still pushed) then I release the button and LED2 turns on the same time I had already set finally the LED2 turns off.

I have the feeling it's not a complicated program but I don't have the knowledge yet to solve it.

I hope you could help me! Thanks

Do you know how to turn on an LED for a period of time ?
See the BlinkWithoutDelay example

The on/off period is set by a variable which you can change by reading a pot using analogRead()
See the analogInput example

UKHeliBob:
Do you know how to turn on an LED for a period of time ?
See the BlinkWithoutDelay example

The on/off period is set by a variable which you can change by reading a pot using analogRead()
See the analogInput example

Yes, I know how to do that. The thing is that I start an " if " inside void loop but once the LED1 turns off it turns on back (even though the button is pushed). so I need to stop the if loop, well I think it's because of the loop.

Use CTRL T to format your code.
Attach your โ€˜completeโ€™ sketch between code tags, use the </> icon in the posting menu.
[code]Paste your sketch here[/code]

Show us a good schematic of your circuit.
Show us a good image of your wiring.
Give links to components.
Posting images:

I need to stop the if loop

There is no such thing as an "if loop"

As requested, please post your code with the attempt to use the StateChangeDetection technique