Then I added new element with own channel. This code is supposed to work even new element is just a "copy" of behaviour of the first element. I cant finish include process. It hangs on 95%. I added new element, channel and getter. Editied code is below and all changes are highlighted in bold. Sorry for not putting it as a code style, wanted to use bold and it is not possible there.
Not ecven luck with this channels setup:
Code: Select all
ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_GENERAL_PURPOSE, getter),
ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_GENERAL_PURPOSE, getter2)
- Raspberry Pi 3+
- RaZberry
- Arduino IDE v1.8.10
Any help please? Im pretty sure, Im missing some detail here and Im too blind to spot it.
// LED pin number
// 13 pin - user LED of Z-Uno board
#define LED_PIN 13
// button pin number
// 18 pin - button(BTN) of Z-Uno board
#define BTN_PIN 18
// channel number
#define ZUNO_CHANNEL_NUMBER_ONE 1
#define ZUNO_CHANNEL_NUMBER_TWO 2
// variable to store current button state
byte lastButtonState;
ZUNO_SETUP_CHANNELS(
ZUNO_SENSOR_MULTILEVEL_GENERAL_PURPOSE(getter),
ZUNO_SENSOR_MULTILEVEL_GENERAL_PURPOSE(getter2)
);
// the setup routine runs once when you press reset:
void setup() {
pinMode(LED_PIN, OUTPUT); // set LED pin as output
pinMode(BTN_PIN, INPUT_PULLUP); // set button pin as input
}
// the loop routine runs over and over again forever:
void loop() {
// sample current button state
byte currenButtonState = digitalRead(BTN_PIN);
if (currenButtonState != lastButtonState) { // if state changes
lastButtonState = currenButtonState; // save new state
zunoSendReport(ZUNO_CHANNEL_NUMBER_ONE); // send report over the Z-Wave to the controller
zunoSendReport(ZUNO_CHANNEL_NUMBER_TWO); // send report over the Z-Wave to the controller
if (currenButtonState == LOW) { // if button is pressed
digitalWrite(LED_PIN, HIGH); // turn the LED on
} else { // if button is released
digitalWrite(LED_PIN, LOW); // turn the LED off
}
}
}
byte getter() {
if (lastButtonState == 0) { // if button is pressed
return 0xff; // return "Triggered" state to the controller
} else { // if button is released
return 0; // return "Idle" state to the controller
}
}
byte getter2() {
if (lastButtonState == 0) { // if button is pressed
return 0xff; // return "Triggered" state to the controller
} else { // if button is released
return 0; // return "Idle" state to the controller
}
}