
One thing a novice might ask is why we opted to employ the millis() function to control the flashing of the LED as illustrated in the previous program. Since so many things are confusing for beginners, I prefer to take things one step at a time (I’d love to hear your thoughts on this and receive your feedback as to whether you like or dislike my approach).

We will return to consider how this test performs its magic before we do so, however, let’s first ponder the question as to why we are using the millis() function in this way.īe warned! Experienced users may consider the following discussions to be a tad trivial in nature, but this column isn’t really intended for presently proficient programmers - instead, it’s targeted at beginners who are befuddled, bemused, and bewildered by everything that is coming their way.
#ARDUINO MILLIS OVERFLOW HANDLING CODE#
In the case of the test performed on Line 22, we noted that this code will happily continue to work, flashing the LED without any change in delay and without any other disruption, even when the millis register overflows back to 0. As part of those discussions, we created the following program, which uses the millis() function to turn a LED On and Off again every 100 milliseconds. In my previous column, we discussed the fact that the time returned by the Arduino’s millis() function will overflow (wraparound) to 0 every 49.71 days.

It’s possible to write one’s programs in such a way that they can accommodate an overflow/wraparound condition in the millis() function, but how does this actually work?
