user53984: 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 ...
Thanks. 

user31105: 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.

Advantage: Easy to program
Disadvantage: Power will continue to be used.

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.

Advantage: Very less power used during the 30 minute delay
Disadvantage: Slightly more programming

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.

Advantage: You can do other tasks meanwhile
Disadvantage: More power usage, slightly more programming


53984: <p>I want to create a 30 minutes delay in my program (Arduino).</p>

<p>which is better <code>millis()</code> or timer for this purpose?</p>

<p>please give me an example to clarify my doubt ...</p>

<p>Thanks. </p>
 31105: <p>It depends on your need:</p>

<p><strong>1. No other activities / main power</strong></p>

<p>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.</p>

<ul>
<li>Advantage: Easy to program</li>
<li>Disadvantage: Power will continue to be used.</li>
</ul>

<p><strong>2. No other activities / battery</strong></p>

<p>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.</p>

<ul>
<li>Advantage: Very less power used during the 30 minute delay</li>
<li>Disadvantage: Slightly more programming</li>
</ul>

<p><strong>3. Other activities</strong></p>

<p>If you want to do now (or later) other code to be executed during the 30 minute wait, use <code>millis()</code>. For example, when you want to extend your project using other libraries that needs a faster than 30 minute response.</p>

<ul>
<li>Advantage: You can do other tasks meanwhile</li>
<li>Disadvantage: More power usage, slightly more programming</li>
</ul>
