Z-Uno operating 2 relays.

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
hansendw
Posts: 2
Joined: 01 Apr 2019 01:37

Z-Uno operating 2 relays.

Post by hansendw » 01 Apr 2019 01:49

I have 2 relays (1 SPDT and 1 DPDT) connected together to run a 3V motor CW or CCW. I am using the example of "Simple Switch". When I turn switch ON motor should run briefly in one direction. When I turn off, it should run briefly in the other direction. It does not work, if fact it does nothing. The wiring is absolutely correct. I ran it as just a plain sketch before incorporating it into a Z-Uno sketch. If I run the LED sample sketch and use pin 14 or 15, the relays operate correctly. Can anyone see what I am doing wrong? The code is as follows:

Thank you, David

#define RELAY_PIN 14
#define DPDT_PIN 15

byte currentLEDValue;

ZUNO_SETUP_CHANNELS(ZUNO_SWITCH_BINARY(getter, setter));

void setup() {
pinMode(RELAY_PIN, OUTPUT);
pinMode(DPDT_PIN, OUTPUT);
}

void loop() {
}
void setter(byte value) {
if (value > 0) {
digitalWrite(RELAY_PIN, LOW);
delay(180);
digitalWrite(RELAY_PIN, HIGH);
} else {
digitalWrite(DPDT_PIN, HIGH);
digitalWrite(RELAY_PIN, LOW);
delay(180);
digitalWrite(RELAY_PIN, HIGH);
digitalWrite(DPDT_PIN, LOW);
}
currentLEDValue = value;
}
byte getter() {
return currentLEDValue;
}

User avatar
PoltoS
Posts: 4585
Joined: 26 Jan 2011 19:36

Re: Z-Uno operating 2 relays.

Post by PoltoS » 04 Apr 2019 00:52

Delay are not allowed in setters and getters. Please read this http://z-uno.z-wave.me/reference/delay/

You should do this work in the loop, only saving the variable in the setter

Post Reply