/* * That is a Simple Sensor Multilevel example * It measures the value on the potentiometer * And sends report to the controller if changed */ // LED pin number #define LED_PIN 13 #define LED_PINN 14 #define LED_PINNN 15 // Last saved LED value byte currentLEDValue; byte currentLEDValuee; byte currentLEDValueee; // next macro sets up the Z-Uno channels // in this example we set up 1 switch binary channel // you can read more on http://z-uno.z-wave.me/Reference/ZUNO_SWITCH_BINARY/ ZUNO_SETUP_CHANNELS(ZUNO_SWITCH_BINARY(getter, setter), ZUNO_SWITCH_BINARY(getterr, setterr), ZUNO_SWITCH_BINARY(getterrr, setterrr)); // next macro sets up the Z-Uno frequency ZUNO_SETUP_FREQUENCY(ZUNO_FREQ_RU); void setup() { pinMode(LED_PIN, OUTPUT); // setup pin as output pinMode(LED_PINN, OUTPUT); // setup pin as output pinMode(LED_PINNN, OUTPUT); // setup pin as output } void loop() { // loop is empty, because all the control comes over the Z-Wave } // function, which sets new relay state // this function runs only once the controller sends new value 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 LED on } else { // if equals zero digitalWrite(LED_PIN, LOW); //turn LED off } // let's save our value for the situation, when the controller will ask us about it currentLEDValue = value; } void setterr (byte valuee) { // value is a variable, holding a "new value" // which came from the controller or other Z-Wave device if (valuee > 0) { // if greater then zero digitalWrite (LED_PINN, HIGH); //turn LED on } else { // if equals zero digitalWrite(LED_PINN, LOW); //turn LED off } // let's save our value for the situation, when the controller will ask us about it currentLEDValuee = valuee; } void setterrr (byte valueee) { // value is a variable, holding a "new value" // which came from the controller or other Z-Wave device if (valueee > 0) { // if greater then zero digitalWrite (LED_PINNN, HIGH); //turn LED on } else { // if equals zero digitalWrite(LED_PINNN, LOW); //turn LED off } // let's save our value for the situation, when the controller will ask us about it currentLEDValueee = valueee; } // function, which returns the previously saved relay value // this function runs only once the controller asks byte getter (){ return currentLEDValue; } byte getterr (){ return currentLEDValuee; } byte getterrr (){ return currentLEDValueee; }
Source: https://habr.com/ru/post/395907/
All Articles