Comparing two Virtual Pin Values

Hi all, extremely new to blynk.

I am starting a project.
What I want is when a value on slider one (virtualPin 3) matches the value on slider two (vitualPin 4) it sets VirualPin 5 to high which turns the led on

I have this code but could someone explain where its going wrong

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";

void setup()
  Blynk.begin(auth, ssid, pass, "", 8442);

  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  Serial.print("V1 Slider value is: ");
  int pinSet = param.asInt(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  Serial.print("Set value is: ");
if (V3 == V4) {
 Blynk.virtualWrite(V5, 255);
} else { Blynk.virtualWrite(V5, 0);

void loop()


First of all, you should use global variables for this to work because you need to access the variables in all functions. Declare them outside of any function to achieve this:

int pinSet;

You are not comparing variables too:

if(pinSet == pinValue)

should be your comparison (with in mind they need to be global).

i have same problem.
how to compare two virtual pin value?

i solved my problem:

sample code written on

BLYNK_WRITE(V1) //Button Widget is writing to pin V1
  int pinData = param.asInt(); 

simple, int command used in BLYNK_WRITE(V1) scope.
this example, everywhere like this.

my solution is this:

int v3=0; 
int v4=0;
int v5=0;

BLYNK_WRITE(V3){v3 = param.asInt();}
BLYNK_WRITE(V4){v4 = param.asInt();}
BLYNK_WRITE(V5){TimeInputParam t(param);
        for (int i = 1; i <= 7; i++) {
                if (t.isWeekdaySelected(i)) {
                          if (t.hasStartTime()){v5=1;}
                          if (t.hasStopTime()){v5=0;}}

void loop() {

  if (v4==0) {if (v5==0) {durum=0;}
              else {durum=1;}}
  else       {if (v3==0) {durum=0;}
              else {durum=1;}}

If you use the “int” command first and then assign the value without “int” in the BLYNK_WRITE(Vx) scope,
many virtual pin values can be used in the loop scope.

sorry for bad english.

@Fatih_Akarsu this is an old topic… albeit a short one :wink: Please take note of the time/date stamps before posting…

As for your question, follow the answer given already. Assign the virtual pin values to a variables just like normally done and compare them as you would any normal Arduino comparison code.

If you still have a particular issue, please create a new topic and supply details of your code.