To get slider value in loop code

Dear Pavel,i need to get slider value as a variable.
Following code works perfectly but slider value is avalable only in"setup area" while i need it in all my code (in loop area too).
In few words, in the following code “dato slider” is always 0 while pinValue followes slider variations.
Can You pls. help me? it’s very importante for me. thanks and best regards.paolo:

#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet2.h>
#include <BlynkSimpleEthernet2.h>

char auth[] = “auth”;
void setup()
{
Serial.begin(9600);
Blynk.begin(“auth”);
}
// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin 1
BLYNK_WRITE(V1)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
Serial.print("V1 Slider value is: ");
Serial.print(pinValue);

}
void loop()
{
Serial.print("dato slider: ");
Serial.println(pinValue);
Blynk.run();
delay(500);
}

Study SimpleTimer i.e. one of the 5 or more libraries you should have manually installed to be able to use Blynk. Study the examples provided by Blynk.

Hi Costas, apologise, due to copy/paste problem initial part of code i posted was incorrect.
Code begin with usual #define BLYNK_PRINT Serial, #include<SPI.H>,#include <Ethernet2.h>,#include <BlynkSimpleEthernet2.h> etc , all items needed to connect BLYNK to internet.
I repeat, the code works , connection to app is perfect.
what i cannot do is to achieve the variable pinValue within the “void loop” but only outside it.
My written english is not so correct so i hope you understand my msg.
again thanks and best regards.
Paolo

Recommended fix, repeated over and over again on this site:

no delays in loop()
nothing in loop() except Blynk.run() and timer.run()
use SimpleTimer

2 Likes

Thanks Costas, issue solved. best regards.