Doorbell button as input

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:

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.

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?

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:

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.

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.

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

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.

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. :slight_smile:

Henry_Best:
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. :slight_smile:

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

Doorbells typically run off transformers, probably 12V or so.

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.

TomGeorge:
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:

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.

schwartzster:

TomGeorge:
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:

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.

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..

TomGeorge, that's good except you inadvertently pointed the LED the wrong way.

Hey I did too, just checkin to see who is awake, LOL... :astonished:
Tom

Finally got around to documenting/showing off my project: Metallophone door chime - Schwartzster.com

Thanks again for your help!

Hi, well done, nice project and I love the sound of tubular type chimes.
Have you got a collection of tunes to play on it?

Tom... 8)

Nicely done! Now if you can get everyone to wear RFID tags, you can have it play different tunes depending on who is at the door.