BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

How to use value of a virtual pin in other BLYNK_WRITE() Functions


#1

How to use value of a vitual pin in others BLYNK_WRITE

Example code


BLYNK_WRITE (V0)
{
  int value = param.asInt();
}
BLYNK_WRITE (V1)
{
  int value1 = param.asInt();
  if (value1 == 1 || value == 1) {    // i want to get value of V0 to use here
      digitalWrite(16, HIGH);
  }
}

#2

FYI, A basic Arduino code question… not Blynk specific.

By using global variables instead of local ones as you have.

https://www.arduino.cc/reference/en/language/variables/variable-scope--qualifiers/scope/


#3

Thanks. It worked. I thinked BLINK_WRITE is function and tried to return the value.


#4

They are still called functions :slight_smile: but they are specifically meant as a conduit with the corresponding widget/purpose in the App.

You can’t call them directly in code like void() functions, but you can “call” them in code via sync commands…

http://docs.blynk.cc/#blynk-firmware-blynktimer-blynksyncvirtualvpin