Go Down

Topic: Doorbell button as input (Read 6746 times) previous topic - next topic

schwartzster

Hello! Long time lurker, first time poster; I tried searching for information and found some tangentially related things, but nothing that really helped with my issue.

I built a chime using a metallophone, solenoids, and an Ardunio. It worked well in my tests using a regular three-leg button, but I am having trouble using my existing doorbell button as an input because it only has two legs. Below is a schematic of the doorbell button; normally power flows through the lightbulb/resistor, pressing the button bypasses the resistor so the full power goes to solenoid in the chime.


To be clear, in my setup the doorbell button is no longer connected to the mains power supply or the solenoid. I connected one leg of the doorbell to the 5v supply and the other leg to pin 11 ("button" in my sketch). Here is the part of my sketch that waits for a button press:
Code: [Select]
void loop() {
  //wait for button press
  val = digitalRead(button);
  if (val == HIGH) {
    tune = random(1,5);


However, it is sensing that the button is pressed all of the time, I assume that enough power is flowing through the resistor to cause the pin to read HIGH. I tried a few other things, like using the 3.3v supply instead of the 5v and connecting a resistor to pin 11 and ground, but with the same result. I know the code is good because it reads LOW and stops playing if I connect pin 11 directly to ground.

How can I connect this doorbell button and configure my code so that it reads LOW until the button is pressed? Super bonus points if the light on the button works, too. Thanks in advance for your input.

nickgammon

Does the light currently light up?

Can you measure how much current the light consumes when on? (ie. connect up the doorbell normally and see what the light itself takes).

Maybe run the light/button through a relay coil. The light itself might not draw enough current to trip the relay, but it would if you press the button?
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

joshuabardwell

An approach you might consider would be to use an analog pin instead of digital. Presumably, when the switch is pressed, input voltage is very nearly 5v. So you could do something like:

Code: [Select]
const int pinNum = 0;
const int pressedThreshold = 1000;

void loop() {
  int a = analogRead(pinNum);
 
  if (a > pressedThreshold)
    tune = random(1, 5);
}


You might have to tweak the pressed threshold a bit.

joshuabardwell

As for getting the switch to light, I'm sorry to say that if it was designed for 120v, I don't think you're going to get very much light at all out of it from a 5v source. The only thing I can think of would be to take the switch apart and replace the incandescent element with a small LED.

TomGeorge

#4
Sep 05, 2013, 10:26 am Last Edit: Sep 05, 2013, 10:34 am by TomGeorge Reason: 1
Hi, do you really need a light in the switch, if not then remove the globe and it will then be a simple switch.
The globes cold resistance is only a few ohms at most so its acting as a closed switch in parallel with your press button.

If you need a light then an LED would be good, as you can via an analogue input described earlier measure the voltage drop across the LED when it is ON.
Pressing the switch will bypass the LED and there will be no volt drop.
So if you set your level to check against as 1Volt,
when the switch is open there will be say 1.6V across the LED,
with switch closed then 0V.
If LED volt drop > 1V then switch is open.
If LED volt drop <1V then switch is closed.

Tom
Everything runs on smoke, let the smoke out, it stops running....

Henry_Best


As for getting the switch to light, I'm sorry to say that if it was designed for 120v, I don't think you're going to get very much light at all out of it from a 5v source.

Please tell me what doorbell push would have mains voltage running through it? Unless, of course, you want to electrocute callers on rainy days.

Wait. That gives me an idea. A 'special' doorbell button for use by JW's. :)

joshuabardwell


Please tell me what doorbell push would have mains voltage running through it? Unless, of course, you want to electrocute callers on rainy days.
Wait. That gives me an idea. A 'special' doorbell button for use by JW's. :)


I do see your point--I was just going off of the diagram the OP posted, though. Switch in parallel with the lamp element.

nickgammon

Doorbells typically run off transformers, probably 12V or so.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

bigred1212

I don't know these things, but I think instead of taking the doorbell lead directly to pin 11 or to pin 11 via a resistor, you should take it to ground via a resistor. Then connect pin 11 upstream of the resistor.  That would seem like a pull down resistor set up to me. But I don't know these things. 

schwartzster


Hi, do you really need a light in the switch, if not then remove the globe and it will then be a simple switch.
The globes cold resistance is only a few ohms at most so its acting as a closed switch in parallel with your press button.


Of course! I can't believe I missed that. After removing the bulb it continued to do the same thing until I connected it like this:
Code: [Select]

3.3 volt ----- doorbell switch ------ resistor ------ ground
                                  |
                                 pin 11


Is that what bigred suggested? It's one of the ways I had tried wiring it up before. Anyway, it works perfectly now! I had considered replacing the incandescent bulb with a LED but I wasn't sure how difficult it would be; after opening the switch to remove the bulb, I don't think it will be very hard at all and I may tackle it tomorrow night.

And for the record, my previous chime used 16v.

Thank you all for the help. I will follow up with a link to photos/video when I get some up in case you're interested.

Henry_Best



Hi, do you really need a light in the switch, if not then remove the globe and it will then be a simple switch.
The globes cold resistance is only a few ohms at most so its acting as a closed switch in parallel with your press button.


Of course! I can't believe I missed that. After removing the bulb it continued to do the same thing until I connected it like this:
Code: [Select]

3.3 volt ----- doorbell switch ------ resistor ------ ground
                                  |
                                 pin 11


Is that what bigred suggested? It's one of the ways I had tried wiring it up before. Anyway, it works perfectly now! I had considered replacing the incandescent bulb with a LED but I wasn't sure how difficult it would be; after opening the switch to remove the bulb, I don't think it will be very hard at all and I may tackle it tomorrow night.

And for the record, my previous chime used 16v.

Thank you all for the help. I will follow up with a link to photos/video when I get some up in case you're interested.

If you connect your LED seperately you could have it on all the time, but that would involve running a third wire from your bell push.

TomGeorge

Use this wiring, you still only need two wires to the button.

The LED is ON, to show where it is, and only goes out when you press the button.
Tom..
Everything runs on smoke, let the smoke out, it stops running....

polymorph

TomGeorge, that's good except you inadvertently pointed the LED the wrong way.
Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8
Multitasking: forum.arduino.cc/index.php?topic=223286.0
gammon.com.au/blink - gammon.com.au/serial - gammon.com.au/interrupts

TomGeorge

Hey I did too, just checkin to see who is awake, LOL...  :smiley-eek:
Tom
Everything runs on smoke, let the smoke out, it stops running....

schwartzster

Finally got around to documenting/showing off my project: http://www.schwartzster.com/chime/

Thanks again for your help!

Go Up