BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Push Notification won't work


#1

I’m not sure why the push notification is not working. but when I disable the servo part, the push notification is working just fine. Hope you can help. Thanks in advance!
Below is my code.

#define BLYNK_PRINT SwSerial
#define BLYNK_PRINT DebugSerial

#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11); // RX, TX
SoftwareSerial DebugSerial(10, 11); // RX, TX
    
#include <BlynkSimpleStream.h>
#include <Servo.h>


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

void notifyOnButtonPress()
{
  int isButtonPressed = !digitalRead(2);
  if (isButtonPressed) 
  {
    
 SwSerial.println("Button is pressed.");
    
     // turn LED on:

   digitalWrite(LED_BUILTIN, HIGH);
  } 
else 
{
    // turn LED off:
    digitalWrite(LED_BUILTIN, LOW);
 }
  
    // Note:
    //   We allow 1 notification per 15 seconds for now.

   Blynk.notify("Someone just press your doorbell!");
}

Servo servo;                                  //the problem start from here 
                                               //if I disable this code or change V1 to D13
BLYNK_WRITE(V1)                          //the programme will run just fine
{
  int pos = param.asInt();
  {
      if (pos==0)
      {
        servo.write(0);
        Serial.println("Open");
      }
      else if (pos==1)
      {
        servo.write(180);
        Serial.println("Open");
      }
  
  Serial.println(pos);  
  }
}                                              //but this servo won't work

void setup()
{
  // Debug console

  SwSerial.begin(9600);

  // Blynk will work through Serial
  //Do not read or write this serial manually in your sketch

  Serial.begin(9600);
  Blynk.begin(Serial, auth);

  // Setup notification button on pin 2

  pinMode(2, INPUT_PULLUP);

  // Attach pin 2 interrupt to our handler

  attachInterrupt(digitalPinToInterrupt(2), notifyOnButtonPress, CHANGE);

  //for LED

  pinMode(LED_BUILTIN, OUTPUT);

  servo.attach(9);

}

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

#2

I edited your post to properly format the inserted code (as instructed for forum viewing).