Simple Switch (FLiRS)

In this example we set up 1 Switch Binary channel and the Sleeping Mode channel. FLiRS — what does it mean? That mean that device wakes up by user request (interrupt) and regularly listening for packets. More about Sleeping mode: here. Channel has two functions:
  • setter — function, which sets new relay state. This function runs only once the controller sends new value.
  • getter — function, which returns the previously saved relay value. This function runs only once the controller asks.
You can read more about this channel and his functions here.
  • Z-Uno board
  • Breadboard
            // 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;
}
        
    
  1. Include Z-Uno into a network (if you do it the first time) or Exclude again (also by pressing the button three times), and then again Include (it will be useful if you already included the device, or just to check if it is not included in the network).
  2. Go to the Elements and here is your device — in this case (in sketch) , you connected a Switch Binary channel, so you see the Switch and its current status (on / off), which you can control from here, by clicking ON you turn the LED on the board