Migrate from Digital pins to Virtual Pins in Button widget

OK , i think i might have solved this flashing issue,huge thanks to @Eugene for this post

Firstly changed the super “inappropriately” named checkPhysicalButton to checkPinState :confused: (that itself might solved all of it ngl)

then change timer accounting for the delay to timer6 = timer.setInterval(1530L, checkPinState);

Lastly call checkPinState for every BLYNK_WRITE like this,

BLYNK_WRITE(V20)
{
  if (param.asInt()) // The button widget sent a 1 (true)
  {
    digitalWrite(D0,HIGH);
    checkPinState();
  }
  else // The button widget is not true, so it's false (0)
  {
    digitalWrite(D0,LOW);
    checkPinState();
  }
}

so that you don’t have to wait for a timer callback.There are still few random flashing of buttons sometimes but very few so can be ignored.

Huge thanks to all for helping me out. :smiley:

I have just one doubt left , is it necessary to call every Blynk.syncVirtual(VXX); separately because I’m just using

  BLYNK_CONNECTED()
{
  Blynk.syncAll();
}

and it seems to work just fine,and I’m calling ` Blynk.syncAll();’ separately in void setup() also, so is that fine too?