Try this… it is something like what I will be adding soon to my Code Collection Topic
Each button press (or release) triggers it’s Function and sets the sate of it’s button.
That Function will check if both button states are HIGH, and if so, turns on the LED
But if one state is LOW then it turns OFF the LED and calls the other Function, which repeats the check.
Thus, regardless of which button gets called pressed first, nothing happens until the second on is also pressed.
This will work with buttons in “button” or “switch” mode for different conditions (e.g. both must be pressed down to activate, one or the other can be a safety switch for the other momentary button, or both can be safety switches)
int Button1, Button2, DevLED=D4; // D4 can also be indicated as pin 2)
BLYNK_WRITE(V1) { // Button 1
Button1 = param.asInt(); // Get value as integer
if (Button1 && Button2 == 1) {
digitalWrite(DevLED, HIGH); // If both buttons ON, turn on LED...
} else {
digitalWrite(DevLED, LOW); // ...else turn OFF LED
}
Blynk.syncVirtual(V7); // Check button 2
}
BLYNK_WRITE(V7) { // Button 2
Button2 = param.asInt(); // Get value as integer
if (Button1 && Button2 == 1) {
digitalWrite(DevLED, HIGH); // If both buttons ON, turn on LED...
} else {
digitalWrite(DevLED, LOW); // ...else turn OFF LED
}
Blynk.syncVirtual(V1); // Check button 1
}