Blink two LEDs at different rates for different period of times

Hello,

I am aware that this query may have been addressed already, however, I am struggling to find it.

Is there a way to blink 2 LEDs at different rate, but switching them off completely at different time delays?

For example:

LED1: Blink at 100ms , stop blinking (turn off) after 2 seconds? LED2: Blink at 200ms , stop blinking (turn off) after 5 seconds?

Thanks.

Is there a way to blink 2 LEDs at different rate, but switching them off completely at different time delays?

Yes

Look at the BlinkWithoutDelay example. It blinks an LED but does not prevent loop() from running. So, a crude way to do what you want is to copy the BWoD portion of the code and using different variables and a different period blink a second LED in loop()

This is not the neatest way to do it but it is easy to understand and implement

for turning off, you might consider counting the number of blinks and suspending any further blinks after the count exceeds some number. resetting count back to zero would re-enable blinking

This is a standard application of blink-without-delay techniques (ie, using millis() instead of delay() for timing, often called "doing more than one thing at a time" and other names too). It is literally the most frequently asked question about Arduino - because the first thing everyone realizes after they see how to blink an LED is that the same methods don't scale to doing much of anything more complicated than that.

See one of the countless guides and threads about it... there are several here...