zunoSendDeviceToSleep()
This function sends the device to sleep.
For ZUNO_SLEEPING_MODE_SLEEPING mode Z-Uno will wake up after wakeup period (set up via Wakeup Command Class) or on INT1 going LOW or Key Scanner detects press.
For ZUNO_SLEEPING_MODE_FREQUENTLY_AWAKE mode Z-Uno will wake up on packet recieved, after a wake up period defined using zunoSetBeamCountWU() or on INT1 going LOW or Key Scanner detects press.
// LED pin number
// 13 pin - user LED of Z-Uno board
#define LED_PIN 13
// Last saved LED value
byte currentLEDValue;
ZUNO_SETUP_CHANNELS(ZUNO_SWITCH_BINARY(getter, setter));
// next macro sets up the sleeping mode
// device will wake up by user request and regulary listening for packets
ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_FREQUENTLY_AWAKE);
// the setup routine runs once when you press reset:
void setup() {
pinMode(LED_PIN, OUTPUT); // setup pin as output
}
// the loop routine runs over and over again forever:
void loop() {
// this function sends the device into sleep
zunoSendDeviceToSleep();
}
void setter(byte value) {
// value is a variable, holding a "new value"
// which came from the controller or other Z-Wave device
if (value > 0) { // if greater then zero
digitalWrite (LED_PIN, HIGH); //turn the LED on (HIGH is the voltage level)
} else { // if equals zero
digitalWrite(LED_PIN, LOW); //turn the LED off by making the voltage LOW
}
// we'll save our value for the situation, when the controller will ask us about it
currentLEDValue = value;
}
byte getter() {
return currentLEDValue;
}