Withdraw slider data ESP32

I’m starting at Blynk, having trouble identifying the value that was passed by the app.
The Blynk tutorials have managed to set the basics, in reading the slider value I’m having difficulties.
Could you take a look at the project what value do I have to put in the "Valor_5 "


#define BLYNK_PRINT Serial


#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

char auth[] = "___________________________";

char ssid[] = "Anderson_oliv";
char pass[] = "__________________";


const int ledPin18 = 18;
const int ledPin19 = 19;
const int ledPin21 = 21;
int valor = 1;
int valor_5 = 0;

   BLYNK_WRITE (V5){ // V5 is the number of Virtual Pin  
   int valor_5 = param.asInt();
   Serial.print("V5 Slider value is: ");
   Serial.println(valor_5);
  } 


void setup()
{ 
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);


  pinMode (ledPin18, OUTPUT);
  pinMode (ledPin19, OUTPUT);
  pinMode (ledPin21, OUTPUT);

  digitalWrite (ledPin18, LOW);     //definir saidas em "0" antes de conectar rede
  digitalWrite (ledPin19, LOW);
  digitalWrite (ledPin21, LOW);
  
}

void loop()
{
  while(valor <= 10){
    digitalWrite (ledPin18, HIGH);
    delay(300);
    digitalWrite (ledPin18, LOW);
    delay(500);
    valor = valor + 1;
    }

  if(valor > 100 ){
  Blynk.run();
  if(Valor_5 >= 500){digitalWrite (ledPin18, HIGH); }else{digitalWrite (ledPin18, LOW);}
  } 
}

Please repost code, properly formatted as instructed, thanks. - Moderator

Blynk - FTFC

Google BACKTICK character :stuck_out_tongue_winking_eye:

Watching you repost again and again was too painful… I fixed it for you :smiley:

1 Like

Now… read through this forum and the Help Documents, And do not fill your void loop with code, use Blynk functions and timer functions instead.

As well as learning the difference in declaring Global and Local variables…

https://www.arduino.cc/reference/en/language/variables/variable-scope--qualifiers/scope/

Thanks for the help.
I would have read these instructions, but I have not seen how it is so important for me to direct the reading of the app value to the function of turning the led on as soon as the value is greater than 500.
this is the main doubt.

The I leave you here, with the answers sitting in front of you… and ignored for lack of reading… much like all your insistant reposting of unformatted code :stuck_out_tongue_winking_eye:

understanding, but with difficulty to interpret the text that was, since it was already read, but I did not understand how to remove any program.
What can not be done is formed the file the correct way.

Sorry for the way the messages are coming, because I’m using google translator, because my language is Portuguese.

Oh, ok, that makes sense…

You need to declare this valor variable as a Global variable in order for other functions and commands to “see” it’s value. Look at that green link above…

at this point in the program, would not the global entry and slader be defined?

No need to re-declare it the 2nd time, inside the BLYNK_WRITE() function

Use like this

BLYNK_WRITE (V5){ // V5 is the number of Virtual Pin
valor_5 = param.asInt();
Serial.print("V5 Slider value is: ");
Serial.println(valor_5);
}

I removed the duplication, but I did not get a good result.

I have read some tutorials, the tutorials are good, but I can not place the information acquired inside the program.
Position.

We don’t always have the time or inclination to dissect everyone’s code here… we teach about Blynk, not as much about programming.

However, I just noticed another issue… You are not even allowing Blynk to run unless your variable meets a specific level… not good!!.. Blynk,.run() needs to run all the time

#define BLYNK_PRINT Serial


#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

char auth[] = "___________________________";

char ssid[] = "Anderson_oliv";
char pass[] = "__________________";

const int ledPin18 = 18;
const int ledPin19 = 19;
const int ledPin21 = 21;
int valor = 1;
int valor_5 = 0;

BlynkTimer timer;


void setup()
{ 
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);

  pinMode (ledPin18, OUTPUT);
  pinMode (ledPin19, OUTPUT);
  pinMode (ledPin21, OUTPUT);

  digitalWrite (ledPin18, LOW);     //definir saidas em "0" antes de conectar rede
  digitalWrite (ledPin19, LOW);
  digitalWrite (ledPin21, LOW);
  timer.setInterval(500L, blink_led);//LED
}
void loop()
{
 Blynk.run();
 timer.run();
}

 BLYNK_WRITE (V5){ // V5 is the number of Virtual Pin  
   valor_5 = param.asInt();
   Serial.print("V5 Slider value is: ");
   Serial.println(valor_5);
  }

void blink_led(){
    if (valor <= 10){
       digitalWrite (ledPin18, HIGH);
    }else{
       digitalWrite (ledPin18, LOW);
       valor = valor + 1;
    }

  if(valor > 100){
    if(valor_5 >= 500){ // <-------------valor with ' v ' instead of ' V '
    digitalWrite (ledPin18, HIGH); 
  }else{
    digitalWrite (ledPin18, LOW);
  }
}
}

I understand.

I’ll run the test here.