   
   vw_set_tx_pin(RFTX_PIN);
   vw_setup(RFTX_RATE);
+
+  // interrupt handler that will be activated when the user presses a button
+  attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), on_button_press, RISING);
+}
+
+#define MILLISEC  1
+#define SECOND    1000 * MILLISEC
+#define MINUTE    60 * SECOND
+#define HOUR      60 * MINUTE
+
+#define SMODE_COUNT 4
+const int smode_delays_ms[SMODE_COUNT] = { 2*SECOND, 1*MINUTE, 10*MINUTE, 1*HOUR };
+
+// disty hack: reset function at address 0
+void(* resetFunc) (void) = 0;
+
+/**
+ * Interrupt handler for the "smode" button.
+ */
+void on_button_press() {
+
+  // cycle through sending modes
+  smode = (smode + 1) % SMODE_COUNT;
+
+  // write new smode value to EEPROM
+  EEPROM.put(EE_SMODE_ADDR, smode);
+  
+  // now we can reset the device with a new smode value
+  resetFunc();
 }
 
 void loop() {
 
+  // turn off power from sensors to save battery
   digitalWrite(SENSOR_POWER_PIN, LOW);
 
   // Wait a few seconds between measurements.

  DEBUG_PRINTLN(msg);
}

int frac2(double x) {
  return abs((x - (int) x) * 100);
}



  // Now sending a the message through RF module
  char msg[32]; // this buffer is used for sending messages through the RF module
  sprintf(msg, "%u %i.%u %i.%u %i.%u",
    sensor_id,
    (int) temp, frac2(temp),
    (int) t, frac2(t),
