Doorbell switch for light control

Moderator: leecollings

Post Reply
rolfo
Posts: 11
Joined: Monday 23 November 2015 20:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Doorbell switch for light control

Post 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?
borgkitty
Posts: 34
Joined: Wednesday 26 October 2016 21:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Contact:

Re: Doorbell switch for light control

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest