Link virtual pin and digital pin

Hi, I need to link a digital pin with a virtual Blynk pin. Hi I need to link a digital pin with a virtual Blynk pin. I have an irrigation system, and I need to schedule the hours when it turns on. Sorry if my English is bad, I’m using a translator. I tried with this code

void setup()
{
  pinMode(2, OUTPUT); // Initialise digital pin 2 as an output pin
}

BLYNK_WRITE(V0) // Executes when the value of virtual pin 0 changes
{
  if(param.asInt() == 1)
  {
    // execute this code if the switch widget is now ON
    digitalWrite(2,HIGH);  // Set digital pin 2 HIGH
  }
  else
  {
    // execute this code if the switch widget is now OFF
    digitalWrite(2,LOW);  // Set digital pin 2 LOW    
  }
}

but it does not work for me.

How have you configured the V0 datastream, and the what sort of widget is attached to V0 and how have you configured it?

Have you tried adding a serial print statement in your BLYNK_WRITE(V0) callback function so you know that it’s being triggered, and what value is being sent via the param.asInt() value?

Pete.