Using virtual pins as condition

Hi

I want to activate/deactivate a part of the loop code by using a blynk botom

(reason= switch between automatic and manual mode, in auto mode, a part of the code should not be executed)

my solution is to use the value of the switch as condition in if (condition of switch)

but how do i read a Virtual pin?

You don’t read a virtual pin per say. You use it to set a value to a variable, then us that variable to do your comparison in your auto/manual control function.

for example:

int control;

BLYNK_WRITE(V2) {
  control= param.asInt();
}

void automate()
{
   if (control == 1)
    {
      //do this stuff
    }
   else if (control == 0)
   {
      //do this other stuff
   }
}
1 Like

You might want to read this…

Pete.

1 Like