 /**
    Sets the MCU into a deep sleep state until a change interrupt is triggered
 */
-void goToDeepSleep() {
+void goToSleep() {
   set_sleep_mode(SLEEP_MODE_PWR_DOWN);
   ADCSRA = 0; // turn off ADC
   power_all_disable (); // power off ADC, Timer 0 and 1, serial interface


void loop() {
  switch (currentState) {
    case SLEEP:
      turnAccelerometerOff();
      // Go to deep sleep until an interrupt occurs
      goToDeepSleep();
      // Proceed to the
      if (buttonPressed) {
        currentState = GAME;
        buttonPressed = false;
      }
      break;
    case GAME:
      // If watchdog is not enabled, then we just arrived from SLEEP state
      if (!watchDogEnabled) {
        turnAccelerometerOn();
        // Set up watchdog to be triggered (once) after the specified time
        setupWatchDogTimeoutOneshot(WDT_1sec);
        watchDogEnabled = true;
        digitalWrite(BUZZER_PIN, HIGH);
      }
      // Go to deep sleep until an interrupt occurs
      goToDeepSleep();
      // We might have gone out of sleep due to another interrupt (i.e. the switch)
      // So make sure that we only get out of this state using the watchdog
      if (watchDogBarked) {
        digitalWrite(BUZZER_PIN, LOW);
        currentState = SLEEP;
        watchDogBarked = false;
        watchDogEnabled = false;
      }
      break;
    default:
      break;

#include <avr/power.h>
#include <avr/wdt.h>

enum WatchDogTimeout {
  WDT_16ms = 0,
  WDT_32ms,
  WDT_64ms,
  WDT_128ms,
