if (millis() - previousMillis > interval) {
// save the last time you blinked the LED
previousMillis = millis();
// if the LED is off turn it on and vice-versa:
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
}
Look for the above in the blink without delay sketch
the first if here is checking millis() which returns how long the sketch has been running. Minus the last time the led blinked, if that value is > interval (1 second by default in this sketch) update the previousMillis with the current time and move on...
doing timing without delay in any situation, is the same thing
I'm not very good at coding, I've tried this code and it works fine. But couls you be more specific how to put timing in? It's not just blink, but blink in different timeline, like "on(0.5 sec)-off(1sec)-on(0.5sec)-off(2sec), and keep repeating this kind loop.
If you expand the part of the code that toggles the state of the LED ("if (ledState == LOW)" etc) with some braces {}, you can put in a variable delay for how long you want the LED to staty in that state.