Functions
The AVR controlls the door/window. If the door is open, the AVR recognizes the new condition. If the door is open for a longer time, there is an alarm.
The green LED on PB 5 shows the operating status.
The red LED on PB 6 is used for the "door open" and "alarm".
"Door open" flashes the red LED.
"Alarm" flashes green and red together.
If the door is closed the AVR goes to sleep mode in the last part of the code.
Every pin change on B, wakes him up.