Page 1 of 1

Doorbell switch for light control

Posted: Monday 22 August 2016 19:39
by rolfo
Hello,
I have the code (I am still noob) - http://pastebin.com/UZFRMXuf . I connected one DHT-22, two relays and switch to ethernet gateway. As I am noob, I used few examples from my sensors library. But I want to change lines 125-137. I want to use doorbell switch (I don't know how to name it correctly). But the idea is: when I push and release switch, the lights turn on, when I do it again, lights turn off. How can I modify the code? I tried this, but unsuccessfully:

Code: Select all

  if (value != oldValue) {
    for (int count = 0; count > 2; count ++) {
     // Send in the new value
     send(msg.set(value==HIGH ? 1 : 0));
     //digitalWrite(5, value);
    }
     oldValue = value;
     
  }
Bonus question - is there any working Arduino debugger when I can see what happens line by line?

Re: Doorbell switch for light control

Posted: Wednesday 16 November 2016 16:40
by borgkitty
you could just count when it goes low /high however you set it up

example if it goes high when you press the button
you would most likely need to add debouncing to your buttons as well there are examples online to do this on adafruit website

if button is depressed(equal high) and lights = on
set light off
execute code to turn lights off
else if button is depressed(equal high) and lights = off
set lights on
execute code to turn lights on