How to use two widgets on same digital pin

Switch to virtual pins and then use code on the device site to transfer those virtual commands to the digital pins.

E.g. For simplicity, I am just using a using a Button Widget (set to Switch mode) on V0 and the Timer Widget on V1 to turn ON or OFF the same LED on a digital pin (including feedback to the Button when the timer kicks in :wink: ) Assuming built in LED on Arduino’s pin 13

BLYNK_WRITE(V0) { // Button Widget function
digitalWrite(13, param.asInt()); // take the state of the Button and send it to the pin
}

BLYNK_WRITE(V1) { // Timer Widget function
digitalWrite(13, param.asInt()); // take the state of the Timer and send it to the pin
Blynk.virtualWrite(V0, param.asInt()); // Send timer state back to button to update it.
}

http://docs.blynk.cc/#blynk-firmware-virtual-pins-control-blynk_writevpin

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

https://www.arduino.cc/reference/en/language/functions/digital-io/digitalwrite/

1 Like