Hi all,
I’m trying to put in place an if clausole that check different virtual pins status.
IF virtual pin V20 and V11 are hight do an action.
Please consider that one virtual pin is in swich mode and the other one is in push mode.
Here my code
BLYNK_WRITE(V20) // ON/OFF
{
int pinValueV20 = param.asInt(); // assigning incoming value from pin V20 to a variable
int pinValueV11 = param.asInt(); // assigning incoming value from pin V11 to a variable
//Serial.print("V20 Slider value is: "); // to seral monitor
Serial.print("V11 Slider value is: "); // to seral monitor
//Serial.println(pinValueV20);
if (pinValueV20 == 1 and pinValueV11 == 1 ) {
//HIGH - ON
Serial.println(F("Pin is HIGH")); // to seral monitor
irsend.sendNEC(0xFB38C7,32); // ON
}else {
//LOW - OFF
}
}
Where I’m wrong? Actually the code give the same feeback… if booth are ON or just one is high; the end clausole ins’t respected.
You just need to set a global variable and the use the BLYNK_WRITE functions to set the flag.
Im going assume that the PUSH mode widget will be the one you want to use to action the irsend.sendNEC(0xFB38C7,32);
bool pinValueV20;
BLYNK_WRITE(V20){ // SWITCH MODE
if(param.asInt()){
pinValueV20 = 1;
} else {
pinValueV20 = 0;
}
}
BLYNK_WRITE(V21){ // PUSH MODE
if(param.asInt() && pinValueV20){ // Check is pinValueV20 is HIGH, and also the PUSH button is held
irsend.sendNEC(0xFB38C7,32); // IR ON (obviously replace this with your own code)
} else {
irsend.sendNEC(0xFFFFFF,32); // IR OFF (obviously replace this with your own code)
}
}