Door bell problem

Ciao ragazzi ho un problema grosso utilizzando questo codice e facendo la prova collegando il pin 2 al gnd ad un pulsante la notifica arriva ma quando provo 2 o 3 volte l’arduino di blocca e mi risulta offline. quindi devo riavviarlo. come mai? dove sbaglio. grazie

Hello guys I have a big problem using this code and doing the test connecting pin 2 to GND to a notification button comes But when I try 2 or 3 times the LOCK Arduino and I know offline. so I have to restart it. Why? where I’m wrong. Thank you

#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxx";

void notifyOnButtonPress()
{
  // Invert state, since button is "Active LOW"
  int isButtonPressed = !digitalRead(2);
  if (isButtonPressed) {
    Serial.println("Button is pressed.");

    // Note:
    //   We allow 1 notification per 15 seconds for now.
    Blynk.notify("Yaaay... button is pressed!");
  }
}

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth);

  while (Blynk.connect() == false) {
    // Wait until connected
  }

  // Setup notification button on pin 2
  pinMode(2, INPUT_PULLUP);
  // Attach pin 2 interrupt to our handler
  attachInterrupt(digitalPinToInterrupt(2), notifyOnButtonPress, CHANGE);
}

void loop()
{
  Blynk.run();
}

un altro problema è che quando aziono un altro relay una tapparella o una luce, l impulso fa attivare la notifica. non ci sto capendo piu nulla. aiutatemi perfavore.

another problem is that when I trigger another relay rolling shutter or light, the pulse does activate the notification. I’m not understanding anything more. help me please let

It probably has to do with the fact that you don’t do any debouncing as they call it. Sometimes interference can trigger pins or act up really weird. I can highly recommend using a capacitor to make a debounce for your physical doorbell button. For example this:

It requires a capacitor and a resistor, very easy to build as you can see. After that you can set the interrupt routine on FALLING or RISING, not CHANGE. That will trigger a lot of noise in the setup you’ve built.