Button state

I just recently used this exact type of example for another topic… How to use two widgets on same digital pin - #3 by Gunner

But I will paste it here as well.


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.
}
1 Like