Automatic dimming 3w led


what @lemeraemail said is absolutely correct on how millis() and lastMillis() work. But he did not explain why to avoid delay and use millis(). when you use a delay, the Arduino stops everything else. So during the delay time, if the Arduino has to perform something else it won’t do it. so the other option is simply comparing millis() value regularly to determine when the desired time has elapsed.


And if you are a newbie, then check ““Blink Without Delay”” example in Arduino under “digital”. That simple example will definitely make the millis() and lastMillis() concepts clear .