Anvay:
yes . i saw the [bwod] code but couldnt understand
What it does is this:
Initialise an interval; this is what in the old way was the delay value
Initialise a variable called previousMillis to 0. This will in future be the record of the last time we did the thing we're controlling. It hasn't been done at the start, so hence it's 0.
Each time through loop(), make a timestamp of the now time, currentMillis.
First time through loop(), check to see if it's time to do the thing. Do that by subtracting the time of the last time we did the thing (previuosMillis, which first time through is 0), from the time now (currentMillsi) and see if that difference is bigger than or equal to the interval.
- If it IS greater than or equal, then it's time we did the thing. So do the thing, and record the time we did that thing, ie copy currentMillis into previuosMillis for next time.
- If it's NOT greater than or equal, do nothing.
Each time through loop(), do exactly the same, except after we've done the thing once, previousMillis will not be 0, it will be the actual time at which we did the thing.