It's possible push a virtual button and disable other button?

this is,
you have to complete my sketch with blynk code too …

//declarations

bool BTN1,BTN2;//flags
int StartRollerTimerUP,StartRollerTimerDOWN;  // timers UP and DOWN
int start, count; //counters

// in setup

  StartRollerTimerUP = timer.setInterval(600L, StartRollerUP); //init StartRollerTimerUP 
  timer.disable(StartRollerTimerUP); // Turn StartRollerTimerUP off

  StartRollerTimerDOWN = timer.setInterval(600L, StartRollerDOWN); //init StartRollerTimerDOWN 
  timer.disable(StartRollerTimerDOWN); // Turn StartRollerTimerDOWN off
 
void StartRollerUP() {
  if (Count <= 10) {
    Blynk.virtualWrite(V51, LOW);
    Blynk.virtualWrite(V54, Count);
  } else {
    timer.disable(StartRollerTimerUP); // Turn HeatingTimer on
    Count = 0;
    Blynk.virtualWrite(V50, LOW);
    BTN1 = false;
  }
  Count ++;
}

void StartRollerDOWN() {
  if (Count >= 0) {
    Blynk.virtualWrite(V50, LOW);
    Blynk.virtualWrite(V54, Count);
  } else {
    timer.disable(StartRollerTimerDOWN); // Turn HeatingTimer on
    Count = 10;
    BTN2 = false;
    Blynk.virtualWrite(V51, LOW);
  }
  Count --;
}


/**************** UP **************/
BLYNK_WRITE(V50) {//roller blind
  start= param.asInt();

  if (start == true && BTN2 == false)  // check if BTN2 is ON
  {
    BTN1 = true;
    Count = 0;
    timer.enable(StartRollerTimerUP); // Turn StartRollerTimerUP on;
  } else {
    timer.disable(StartRollerTimerUP); // Turn StartRollerTimerUP off
    BTN1 = false;
  }
}

/**************** DOWN **************/
BLYNK_WRITE(V51) {//roller blind
  start= param.asInt();

  if (start == true && BTN1 == false)  // check if BTN1 is ON
  {
    BTN2 = true;
    Count = 10;
    timer.enable(StartRollerTimerDOWN); // Turn StartRollerDOWN on;
  } else {
    timer.disable(StartRollerTimerDOWN); // Turn StartRollerDOWN off
    BTN2 = false;
  }
}


V50 and 51 as styled button (switch mode)
V54 level widget

22-023781

1 Like