However when I try to setup multiple sensors, I see the sensors, but changing the state on the inputs doesnt change the state on vera. I have put debugging into the sketch and can confirm that the loop is correctly setting variables accordint to their state and I can confirm that the getter is being called when the state changes and returns the correct value. My sketch is as follows
Code: Select all
// LED pin number
// 13 pin - user LED of Z-Uno board
#define LED_PIN 13
ZUNO_SETUP_CHANNELS(ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_GENERAL_PURPOSE,getter1),ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_GENERAL_PURPOSE,getter2),ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_GENERAL_PURPOSE,getter3));
byte last1,last2,last3;
// the setup routine runs once when you press reset:
void setup() {
pinMode(LED_PIN, OUTPUT); // setup pin as output
pinMode(11,INPUT_PULLUP);
pinMode(10,INPUT_PULLUP);
pinMode( 9,INPUT_PULLUP);
}
// the loop routine runs over and over again forever:
void loop() {
// loop is empty, because all the control comes over the Z-Wave
byte current;
current = digitalRead(11);
if (current != last1) {
last1 = current;
zunoSendReport(1);
}
current = digitalRead(10);
if (current != last2) {
last2 = current;
zunoSendReport(2);
}
current = digitalRead(9);
if (current != last3) {
last3 = current;
zunoSendReport(3);
}
}
byte getter1() {
if (last1 == 0)
return 0xff;
else
return 0;
}
byte getter2() {
if (last2 == 0)
return 0xff;
else
return 0;
}
byte getter3() {
digitalWrite(13,last3 ? 0xff:0);
if (last3 == 0)
return 0xff;
else
return 0;
}