How to poll the value of a vitual pin

Hi all

In my project I would like to poll the value of a virtual slider when I press a virtual button.

  • V5 is a push button on Blynk app
  • I would like to know the value of V4. V4 is a slider on the blynk app.

thx

Andreas

BLYNK_WRITE(V5) //Set Temperature Button
{
  if ( param.asInt() == 1 )
  {
    Serial.print("Pressed Button Set Temp. Temp of slider is:");
    Serial.println(Blynk.virtualRead(4));
  }
}

Any work arround?

Andreaw

Sorry, we didn’t understand your question from the first time :). It’s doable.

We currently don’t have:

Blynk.virtualRead(4)

You need to declare a global variable and put slider value to this variable:

BLYNK_WRITE(V4) // Slider widget writing to V4
{ 
    sliderValue = param.asInt(); //sliderValue is a global variable you declared before void setup()
}

//then use your code

BLYNK_WRITE(V5) //Set Temperature Button
{
  if ( param.asInt() == 1 )
  {
    Serial.print("Pressed Button Set Temp. Temp of slider is:");
    Serial.println(sliderValue);
  }
}


Yes, this is what i thought.

But how can you get the initial value when arduino boots?
(I want to respect what is actually on the screen of the app).

thx a lot

Andreas

We call this feature “Hardware state handling”. You can vote for it here. At the moment it is not implemented, but we are very close to it.