There are various notions of efficiency, depending on what resource you
want to optimize for. For a battery-powered project, the most relevant
is likely to be energy-efficiency. Then, your code may not be the main
issue.
If you plan for your LED to be turned on continuously, this is going to
significantly tax your battery. Your first concern should then be to
minimize the power drain of the LED itself: make the current through it
as low as convenient, and maybe consider powering it through a DC-DC
converter in order to avoid wasting too much energy in the series
resistor. If your Arduino has a power-indicator LED, you should also
unsolder it. If it has a second microcontroller that it always on (like
the Uno), you should find a way to disable it.
Regarding the energy consumption of the CPU running your code, the only
way to be energy-efficient is to have it sleep most of the time, and
wake it up only when there is useful job to do. Unfortunately, the
Arduino core provides no standard way to sleep. You may have to look
into architecture-specific solutions, or search for a library that
abstracts this for you. On an AVR, for example, you may be able to
significantly lower the consumption by calling
sleep_mode()
once within your loop()
. This will put your
device in a “shallow” sleep mode, and it will be woken up by the next
timer interrupt (these happen every 1.024 ms). If you want to go to
deep sleep, you will have to arrange a wake-up source other than the
timer interrupt. An RTC could be an option. However, if you do not need
the 30 minute period to be accurate, you may as well use the
watchdog timer (which is ultra-low power) as an interrupt source.
There are many other things to be aware of when you care about power
consumption. I recommend reading Power saving techniques for
microprocessors, by Nick Gammon, which covers most of the
relevant issues. Note, however, that it discusses mostly AVR.