Blinking two LEDs in and out of phase

Thanks!

is it possible doing a for loop like I did in your previous version with delay() :

void blink(unsigned long onTime, unsigned long phaseDifference, unsigned long rate,uint16_t repetitions)
{
  for (int i = 0; i < repetitions; i++)
  { 
  if (phaseDifference < onTime)
  {
    digitalWrite(led1, HIGH);
    delay(phaseDifference);
    digitalWrite(led2, HIGH);
    delay(onTime - phaseDifference);
    digitalWrite(led1, LOW);
    delay(phaseDifference);
    digitalWrite(led2, LOW);
    delay(rate - (onTime + phaseDifference));
  }
  else
  {
    digitalWrite(led1, HIGH);
    delay(onTime);
    digitalWrite(led1, LOW);

    delay(phaseDifference - onTime);

    digitalWrite(led2, HIGH);
    delay(onTime);
    digitalWrite(led2, LOW);

    delay(rate - (onTime + phaseDifference));
  }
}
}

then at the blink function inside the void loop() the last element is for how many repetitions each blink function:

void loop() {


blink(50,0,400,3); // 3 repetitions
blink(50,100,1000,5); //  5 repetitions

Is it possible doing the same with the new version of your code that is not using delay()