Sending data, value from a Blynk slider to the Hardware , e.g. ESP8266

Hi people,
i have problemes to send the data from a slider in blynk to the hardware so i can use the value as
INT or long variable into my programm.

I make a slider in blink and name it Virtual Pin15.
In esp8266 I do, what I found in Blynk documentation:

**BLYNK_WRITE(V15) //Button Widget is writing to pin V15**

{
** int pinData = param.asInt(); **
}

After compling ,there comes the error:

:\Arduino_Rainer\1__Programme_Rainer\8_Test_ESP8266_Wifi_Blynk\Test auf PCB_KOR1\Test_PCB_KOR1_V1\Test_PCB_KOR1_V1.ino: In function ‘void setup()’:
Test_PCB_KOR1_V1:76:1: error: a function-definition is not allowed here before ‘{’ token
{
^
exit status 1
a function-definition is not allowed here before ‘{’ token

what I doing wrong ??

Best Regards
Rainer

Impossible to say based on this snippet of Unformatted code.
Please post your compete sketch, correctly formatted with triple backticks at the beginning and end of your code.
Triple backticks look like this:
```

Pete.

Hi Pete,
I do only copy this part, because this is the only part which was given in Blynk dokumentation
See here…

Exactly this from Docu I copy in my code.
Without this part my Sketch was working fine.

If I Insert this part in Loop at any location the error comes.

I only want to add a slider value from Blynk to my Sketch.

Best Regards
Rainer

I thing the Code in Docu

was not clear discripted or bad …

now i do this…before void setup:

[Unformatted code removed by moderator]

now i do not get any errors.
for my understanding.
shopuld now not come in serial monitor each time i use the slider a value on screen )
there comes nothing and i do not have the variable “pinValue” not in my
sketch for use.

What are i doing wrong ?

if i try to use the pinValue in loop there comes that the
‘pinValue’ was not declared in this scope

now it works fine, but i do not get the value in loop.

if i try to use the pinValue in loop there comes that the
‘pinValue’ was not declared in this scope

How i Get the value in Loop as variable ?

You don’t seem to be very good at following instructions, or taking advice!

I’ve removed your unformatted code, as it didn’t have triple backticks.

Judging by the error message, you have an unmatched pair of curly brackets within your sketch, but it’s impossible to help you with this as you refuse to post your complete sketch, and refuse to use triple backticks when posting code to the forum.

Pete.

Thanks, Pete, but know all works fine like documentation.
no more eroors, so its not necessary to send the hole code.

The value comes after sliding in serialmonitor, fine !

The last point and question is how i get the Int Value from the defines into my void loop.
There comes altimes the message that the ‘pinValue’ was not declared in this scope
In loop, but in the defines are the pinValue declared as INT. ?

[Unformatted code removed by moderator]

So, how can I use the “pinValue” in the voidloop?

Now I send the code and now I do not get any answers anymore…

We have community rules for good reasons.

If you continue to post unformatted code your account account will be suspended.

Pete.

I am sorry, I am an beginner and follow your wish to upload the code. That I do, why you want to have it. I do not know how to upload in formated wise. I make copy and paste.
But I must say… You are not a friendly person for beginners… I do want you want and upload the code. I make a copy of formated code and copy in your field here. In your field the formating was lost.
I do this the first there and you want to kick me out…
You are not a beginner friendly person!
No help, only bad words…

So inexperienced persons and beginners become from you bad words, and no help or tips to make it better… The simplest way… Kick them out.
No chance and hint how to make it better.
The reason why I need help in this forum and the problem I have was totally in the background.

Rainer

When you signed-up to this forum, you received an email with a link to the community rules, which explain how to post code.
When you created this topic, it was pre-populated with guidelines about the information to provide, including details of how to post code.

In post #2 of this topic I explained once again how to post code, and gave you some triple backticks that you could copy and paste at the beginning and end of your code, in case you had difficulty finding the correct symbol on your keyboard…

You have ignored al of this information, and posted unformatted code multiple times since post #2

I do not know how to explain it any clearer!

Pete.

Hopefully this time I do it right. This is the sample I have question about.

#define BLYNK_PRINT Serial


#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>

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

// 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
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  Serial.print("V1 Slider value is: ");
  Serial.println(pinValue);
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth);
}

void loop()
{
  Blynk.run();
}

I hope I understand in a right way and ask again.

How can I use the variable “pinValue” in my Void Loop ?
What I must do that this variable is also declared for using in Void Loop

Regards
Rainer

To use a variable anywhere within your code it needs to be declared globally rather than locally within the BLYNK_WRITE function.
This isn’t specific to Blynk, it’s a standard C++ programming principal.
If you search this forum, or the internet for “variable scope” then you’ll learn more.

However, you shouldn’t be doing variable comparisons/operations within your void loop - Blynk doesn’t like it.
Instead, you should put those operations into a function and call that function with a timer. More info here…

Pete.

OK, I understand, now it works.
Thanks Pete.