Enable / Disable widget button

Hi.

I thought it would be good if our widget button could be enabled and disabled by program, as we needed it, indicating it on the screen of our phone with a color change, enabled with the color we have chosen, and disabled with a gray color, for example. .

A greeting BlackTiger.

you can disable button by script and change color too
:wink::wink:

What to change color if I knew what could be done, but to enable or disable it by script unknown, could you tell me how it is done.

Thanks BlackTiger

Widget parameters can be changed via code… as per Documentation.

http://docs.blynk.cc/#blynk-firmware-virtual-pins-control-blynksetpropertyvpin-property-value

http://docs.blynk.cc/#blynk-main-operations-change-widget-properties

Widgets are always “enabled”… but in your code you can set flags or parameters that determine whether to acknowledge, for example a button press, or not, depending on your other code parameters… lots of discussion and examples about this already in this forum.

Search and you shall find.

1 Like

@BlackTiger
hope this can help you

const String BLYNK_BLACK =   "#000000";
const String BLYNK_YELLOW =  "#ED9D00";

BLYNK_WRITE(V49) //button to be disable
{
 if (ButtonPressed == false) {
   Serial.println("Button V49 is disable");
 } else {
   Serial.println("Button V49 is enable");
 }
}

BLYNK_WRITE(V50) //button to disable V49
{
 int ButtonState = param.asInt(); // assigning incoming value from pin V50 to ButtonState
 if (ButtonState == 1) {
   ButtonPressed = true;
   Blynk.setProperty(V49, "color", BLYNK_YELLOW);
   Blynk.setProperty(V49, "onLabel", "ON");
   Blynk.setProperty(V49, "offLabel", "OFF");
   Serial.println("Button V49 enable");
 } else {
   ButtonPressed = false;
   Blynk.setProperty(V49, "color", BLYNK_BLACK);
   Blynk.virtualWrite(V49, LOW);
   Blynk.setProperty(V49, "onLabel", "disable !");
   Blynk.setProperty(V49, "offLabel", "disable");
   Serial.println("Button V49 disable");
 }
}
1 Like

Hello again.
Thanks for the example that Alexis_Cabrera has given me, I will work on it to carry out my program with Blynk.

A greeting BlackTiger.

1 Like