The following example code demonstrate the implementation of the power down mode on the AVR.
The application light a LED and flash a LED.
The key can be used to switch both LEDs on and off.
If the LEDs are on, a timeout of 20 seconds switch off also.
During the off state, the power down mode was entered.
The code use a very efficient key debouncing routine:
It use also a macro to access portpins as bitvariables: