I want to create a 30 minutes delay in my program (Arduino).
which is better
millis() or timer for this purpose?
please give me an example to clarify my doubt ...
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It only takes a minute to sign up.Sign up to join this community
It depends on your need:
1. No other activities / main power
If during those 30 minutes (I guess), the MCU does not have to do anything else (except maybe handling some short interrupts), than you can use a delay. You can use this if your power source is an adapter, but you waste a lot.
2. No other activities / battery
If you have the same conditions as above, but using a battery, than as Juraj mention, use the sleep functionality of the Arduino. You need an (external) real time clock or other circuitry to activate the wakeup signal after 30 minutes.
3. Other activities
If you want to do now (or later) other code to be executed during the 30 minute wait, use
millis(). For example, when you want to extend your project using other libraries that needs a faster than 30 minute response.