The Virtual Pins

How do I use the virtual pins ? For example the LED settings require V0 - V31, but what can I do with them and how ?

I am using a SparkCore successfully with simple sliders and buttons.

Love it !

Pat

I’m currently creating a short guide on this. I’ll post it here soon…

Cheers!

1 Like

Also see if this is helpfull to getting you there

https://github.com/blynkkk/blynk-library/blob/master/examples/Widgets/LED/LED.ino

Thanks, looking forward. And thanks for the very quick reply.

Thanks very much. Will see if I understand this :slight_smile:

Hey @jdeere12 ,
here is the doc.
It is still in progress, so please write any questions you have and we will update the doc.
Thanks!

1 Like

Thanks,

I begin to see, but probably need an example for the SparkCore .

I have a little widget built on my iPhone with 3 buttons controlling D0,D1,D2 which are wired to a tri-color LED. So I can get different color combinations. Also have a button on D7 to switch the onboard LED on and off and a slider on A0 with an LED wired to A0 … so I can change brightness etc.

Suppose I also wanted to have 3 LEDs in the app on the iphone, Red, Green, Blue that go on (respectively) when D0, D1, D2 are high (or low).

How would I do that … the LEDs in the app are, for example, on V0, V1, V2 …

Make any sense ?

This is the code that is running …

//#define BLYNK_DEBUG // Uncomment this to see debug prints
#define BLYNK_PRINT Serial
#include "blynk/BlynkSimpleSparkCore.h"

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

void setup()
{
  Serial.begin(9600);
  delay(10000); // Allow board to settle
  Blynk.begin(auth);
}

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

@patmolloy
You could do something like this:

boolean state0 = LOW;
boolean state1 = LOW;
boolean state2 = LOW;

void LEDcheck() {

if (digitalRead(0) != state0) {
state0 = digitalRead(0);
Blynk.virtualWrite(0, state0);
}
if (digitalRead(1) != state1) {
state1 = digitalRead(1);
Blynk.virtualWrite(1, state1);
}
if (digitalRead(2) != state2) {
state2 = digitalRead(2);
Blynk.virtualWrite(2, state2);
}
}

and then call the function LEDcheck() in your void loop().
This way the state of the digital pins are continuously copied to the virtual pins.
I dont know if this is the best way to do it, but it kinda works :smile:

1 Like

hmmm…the manual is not for beginners…
just wanted to test to use analogWrite with a virtualPin:
So want to use a slider aas virtualOutput=1, and app should send slider value to myarduino which will fade an LED:
BLYNK_WRITE(1) { analogWrite(13, param.asInt());}

That doesnt work but thats how I understood your tutorial…so please make better and easier examples for beginners

Thx
Thorsten

//EDIT:Sorry…it worx! Just put the line inside the loop() and not as an own function.

I’ll give these a try. Beginner status here !

Hi,

thx for the documentation! Is there a way read a specific virtual pins value like “Blynk.virtualRead(pin)” ?

Thanks,
Tobias

No, not now at least.
You should use BLYNK_WRITE() functions which are called when the value changes.

I have a question. when I use the function BLYNK_WRITE() on a certain pin and activate it using a push button in the app, does the function activate over and over again untill I let go or does it activate only once, and I have to let go and push the button again to activate it once more?
I would try for myself but i don’t have my equipment with me.
thank you bery much :slight_smile:
P.S I am using a standalone esp8266

yes, some complete examples would be nice

@omriman067

It depends on which mode the Button Widget is. It has two modes: PUSH or SWITCH. In PUSH mode, when you press the button, 1 is sent to device, when you release- 0 is sent. Switch works like a switch :smile:

@Scyl
As always, the easiest way is to load our example sketch, open the Serial Monitor, and look at incoming data.

Any solution to read virtual pin value when Arduino re-start?
BLYNK_WRITE called only when value change but if arduino reset I would like to read previous value set for the virtual pin.

Thank you,

Look at the “Sync” example. Doc.

Hai Link is brooken :sweat:

@Frenkie123 which link?

As always, the easiest way is to load our example sketch,168 open the Serial Monitor, and look at incoming

Then when you presson the skets the page is no longer availeble