#include <avr/interrupt.h>
#include <avr/sleep.h>

// Set to "1" to enable debug output, 0 (or else) disables serial output
#define DEBUG 1

#if DEBUG == 1
  #define Debugln(x) Serial.println(x)
#else
  #define Debugln(x)
#endif

// Define relais pins 
#define relaisPin_1 11
#define relaisPin_2 12

void setup() {
  Serial.begin(9600);  // open the serial port at 9600 bps

  // Init pins HIGH
  digitalWrite(relaisPin_1, HIGH);
  digitalWrite(relaisPin_2, HIGH);
  pinMode(relaisPin_1, OUTPUT);
  pinMode(relaisPin_2, OUTPUT);

  Debugln("Hello!");
}

void loop() {
  delay(2000);  // Wait for 2 seconds
  Debugln("Enable power rail #1");
  digitalWrite(relaisPin_1, LOW);  // Poweron relais #1

  delay(2000);
  Debugln("Enable power rail #2");
  digitalWrite(relaisPin_2, LOW);  // Poweron relais #2

  delay(50);  // wait for UART to finish
  stop();
}   

void stop() {
  // Turn microcontroller off
  Debugln("All done, powering off. Goodbye.");
  delay(100);  // wait for UART to finish

  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  cli();
  sleep_mode();
}
