Delay() not working

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
Posts: 2
Joined: 08 Feb 2019 18:33

Delay() not working

Post by johnny_boy_1984 » 11 Feb 2019 12:44


I am trying for my first project to digitalWrite several pins high or low with a delay, but the delays are ignored. I used the control relay example and added extra output pins. The result is all three defined pins are going on and off simultaniously instead of with a delay.

Code: Select all

 * This example shows basic Switch Binary functionality
 * Control an external relay on pin 13

// pin number, where relay is connected
#define RELAY_PIN9     9
#define RELAY_PIN10    10
#define RELAY_PIN11    11

// variable to store current relay state
byte lastSetValue;

// next macro sets up the Z-Uno channels
// in this example we set up 1 switch binary channel
// you can

void setup() {
  pinMode(RELAY_PIN9, OUTPUT); // set up relay pin as output
  pinMode(RELAY_PIN10, OUTPUT); // set up relay pin as output
  pinMode(RELAY_PIN11, OUTPUT); // set up relay pin as output

void loop() {
  // loop is empty, because all the control comes over the Z-Wave

// function, which returns the previously saved relay value
// this function runs only once the controller asks
byte getter() {
    return lastSetValue;

// function, which sets new relay state
// this function runs only once the controller sends new value
void setter(byte newValue) {
  // newValue is a variable, holding a "value"
  // which came from the controller or other Z-Wave device
  if (newValue > 0) { // if greater then zero
    digitalWrite(RELAY_PIN9, HIGH); //turn relay on
    digitalWrite(RELAY_PIN10, HIGH); //turn relay on
    digitalWrite(RELAY_PIN11, HIGH); //turn relay on
  } else {            // if equals zero
    digitalWrite(RELAY_PIN9, LOW); //turn relay off
    digitalWrite(RELAY_PIN10, LOW); //turn relay off
    digitalWrite(RELAY_PIN11, LOW); //turn relay off

  // save the new value in a variable
  lastSetValue = newValue;

User avatar
Posts: 4483
Joined: 26 Jan 2011 19:36

Re: Delay() not working

Post by PoltoS » 14 Feb 2019 23:17

delay is not allowed in getters and setters. Please check the manual.

This is because setter and getter is like an interrupt

Post Reply