Problem with variable scope? [More information required]

Hello all…i think i’ve a “modified” problems related to this topic…

how to “Reuse” Virtual Pin in other funnction or other void?

here is my code …

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

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

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

// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin 1

// V3 LED Widget is blinking

void blinkLedWidget()
if (y == 1)

digitalWrite(D4, HIGH);}
else if (y == 0)
digitalWrite(D4, LOW);


int y = param.asInt();
if (y == 1)
digitalWrite(LED_BUILTIN, HIGH);}
else if (y == 0)
digitalWrite(LED_BUILTIN, LOW);

void setup()
  // Debug console
 Blynk.begin(auth, ssid, pass, "", 8442);
 Blynk.notify(" Gawat koneksi putus");
 timer.setInterval(1000L, blinkLedWidget);

void loop()

Hi @LOKI13 I’ve moved this to its own topic, mostly because you’ve not really explained the issue clearly.

I’m guessing (as I’ve said in the title that I’ve given to this new topic - please feel free to edit it) that your issue is with variable scope.

If you want to use the value that you’re obtaining from the V10 widget in the BLYNK_WRITE(V10) callback function elsewhere in your code then the variable that you use to store value needs to be global rather than local.

is telling the code to create a local integer variable called y and store the value from the widget ion this variable. Because it’s local, it can only be referenced within the BLYNK_WRITE(V10) function.


Hello Mr Pete…

Yes perfect title ( for my problems)

thats right… before i asking this question i do open blynk example…get data…etc…,and watch youtube video (Anna) …but all of them…they are use local variable…

Ive already usually arduino & Virtu*@# which is set a global variable even before void setup

and i think blynk is something new for me & interesting

Do you have a simple code that use “global” variable ?

lets say just blink a led using global Virtual memory,not digital pin and will be “acknowledge” to other Void



Google “variable scope in C++” and you’ll understand how to move the variable declaration to make it global.