UNLOCK BUTTON
NO EFFECT
.
.
.
.
PRESS 2 sec to UNLOCK
//V50 and V51 styled button
WidgetLED redLed(52);
WidgetLED greenLed(53);
/**************** LOCK UNLOCK **************/
BLYNK_WRITE(V50) { // button press 2'' to unlock
if (param.asInt() and !LongPress ) {
ButtonTimer = timer.setTimeout(2000, LongPressDetect);
ButtonPressed = true;
} else { // Button released
ButtonPressed = false; // Reset the button press flag
if (!LongPress) {
timer.deleteTimer(ButtonTimer);
// Reset LongPress flag and LED
LongPress = false;
greenLed.off();
redLed.on();
}
}
}
void LongPressDetect() {
// button still depressed
if (ButtonPressed) {
LongPress = true;
greenLed.on();
redLed.off();
Blynk.setProperty(V51, "offBackColor", BLYNK_GREEN);
Blynk.setProperty(V51, "offLabel", "UNLOCK");
Blynk.setProperty(V51, "onLabel", "LOCK");
}
}
BLYNK_WRITE(V51) { // actuator button
if (param.asInt()) {
if (LongPress = true) {
ButtonPressed = false;
LongPress = false;
greenLed.off();
redLed.on();
Blynk.setProperty(V51, "offBackColor", BLYNK_RED);
Blynk.setProperty(V51, "offLabel", "LOCK");
Blynk.setProperty(V51, "onLabel", "LOCK");
}
}
}