Waiting for light to turn off before activating the next one

  arduino, automaton, c++, nodemcu

I want to make a program with the Automaton library that turns four lights on, one after the other, continuously. The program is supposed to activate when a button is pressed. Each light is lit for 600ms and the next light gets activated after 300ms. The last light is supposed to turn off fully before the first one gets activated again.

The first time the program runs it works fine. All lights turn on when they are supposed to.
However the problem appears when the light goes into the second loop because now the first light gets activated while the last light is still on, which is not supposed to happen.

Is there a way to implement some kind return or stop event which lets the program know to wait until the last light is turned off before going into the next iteration of the loop?

Here is what I have tried so far. The order in which the lights are supposed to turn on is: blue1 -> blue2 -> red -> green

#include <Automaton.h>

Atm_led blue1, blue2, red, green;
Atm_button button;
int on = 600;
int off = 300;

void setup() {
    blue1.begin(D0, true).blink(on);
    blue2.begin(D4, true).lead(300).blink(on);
    green.begin(D6).lead(900).blink(on); // I tried to use onFinish() here but that didn't work


void buttonpress(int idx, int v, int up) {
    if (v) {
        // I tried to add a delay() here but that didn't work at all

void loop() {

Source: Windows Questions C++