A collection of millis examples that make it easy for you to use Millis.
Millis can be one of the most confusing as well as frustrating pieces of arduino code to use. This page contains code examples that you can modify to suit your needs.
The book on the left is a classic reference book. If you are interested in Arduino at all, this book should be in your files.
Introduction to Arduino is free. Click on the image to get a free copy
Use Millis Instead Of Delay
Millis is particularly useful when you want to add a delay in a sketch but either want to or must not use the code delay(time);.
For your conveniecnce this code will do that for you.
unsigned long targetTime=0
targetTime=millis()+10000 //how long you want to wait
Then in your main loop
If ( targetTime > millis() )
targetTime = 0 //or next interval
// Do timed action
Millis can, however be bused in many other ways. The link below shows several ways that it can be used.
Fun With Millis Examples – Has a woki sketch for a series of examples.. This is a github page that in addition to the code has Wokwi simulations completed for you. You can click on them and see how they really work.
There is a complete library of Arduino project in our site at Arduino Projects