1

I am trying to create a smart doorbell, but my problem is that doorbell makes ring any time when nobody touch the button.

I think that the problem is caused for the incorrect way to connect the analog wall button to arduino GPIO.

Basically my wiring diagram is:

Analog Input (A0) to 1 pin of the button. Ground of the Arduino (GND) to the other pin of the button.

When the button is pressed, the circuit is closed, and doorbell makes ring!

But surely this is not the way to connect a button on the wall because the doorbell sounds on its own.

I leave a picture of the button nk

  • Your problem is the lack of pullup/pulldown resistor. Search and read about it. – user31481 Sep 21 '17 at 18:27
  • Can you provide a schema over the button, power source (AC or DC and voltage) and doorbell (current consumption), preferable with type of component. Or just more data is needed. – MatsK Sep 21 '17 at 19:16
3

jose can u c is absolutely right, you need a pullup. No need to change your wiring however: the Arduino has built-in pullups on all the inputs. You just have to activate them:

const uint8_t buttonPin = A0;  // or any other pin for that matter

void setup()
{
    pinMode(buttonPin, INPUT_PULLUP);
}
  • This is true. But in some cases where the wires are long, induced noise can overpower the relatively weak internal pull-up resistors. If this happens with external pull-ups, you can decrease the resistance value to increase the pull strength, but with internal pull-ups, you cannot change them. – jose can u c Sep 21 '17 at 19:36
2

You need to have a pull-up resistor, see circuit below.

You do not need to connect it to an Analog pin, but a digital pin. Without a pull-up or pull-down resistor, the voltage on the input pin "floats" anywhere, and can give false triggers. This circuit forces the pin to either be 5V or 0V.

schematic

simulate this circuit – Schematic created using CircuitLab

  • This is a good answer; but @santiago-dantuoni should clearly mention if its an AC powered doorbell or a DC powered doorbell; – techniche Sep 21 '17 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.