Local and Global Variables

I created slider in blynk and I want to get the slider value to outside variable (Not inside BLYNK_WRITE(Vx) )

How is it possible to get the variable out of the BLYNK_WRITE() and use it for global variable . When i define the variable global the value display always shows 0. Can anyone cmnt code with slider value assign to outside variable from BLYNK_WRITE()

Thanks for your help.

You are probably re-declaring the variable as local, by having an int Or float Command before your variable name within the BLYNK_WRITE function, but itโ€™s impossible to say with any certainty as you havenโ€™t bothered to share your sketch.


1 Like
int m;

  int n = param.asInt();   

I want to assign โ€˜nโ€™ (Inside BLYNK_WRITE) value to โ€˜mโ€™ (Out side integer variable).

As I suspected, you are re-declaring m inside your BLYNK_WRITE function.

Change it toโ€ฆ

n = param.asInt();

and declare n as a global variable, not m


1 Like

Thank you so much. It works!!!