duration on metro lib

hi

thanks MarkT, move -lastTime- make run good. yes, need to synchronize it with ON process...

You want the LED on for 100ms every 250ms?

yes that's right, but interval and duration can change in the time, I using sensor for control it...

code is like this :

unsigned long lastTime = 0;
int duration = 100; // duration time - Led is ON -
unsigned long currentMillis;

Metro metro0 = Metro(500); 

void setup()
{
  Serial.begin(9600);
  
  pinMode(LED0,OUTPUT);
  }

void loop()
{

   currentMillis = millis(); 
  
  if (metro0.check() == 1) {  // check if the metro has passed its interval (default = 500 ms) 
  
    digitalWrite(LED0,HIGH);
    lastTime = currentMillis;
  }
  
     if (currentMillis - lastTime  > duration) {
     digitalWrite(LED0,LOW);
         }

Thanks & best
0-0