Newbie question regarding virtual pins

Hi I am trying to use blink to interface with a current program I have compiled and working, I want to add Blink to read some virtual pins, I have no clue how to do this. Is there any good quick references or code that can help me out, I’ll be searching on my own in the mean time. It appears its not easy to assign data from another program to a virtual pin, or not yet anyway. Thanks any help would be greatly appreciated. Thanks. Mike

Start here: http://help.blynk.cc/blynk-basics/what-is-virtual-pins :slight_smile:

2 Likes

thanks I will start reading now

1 Like

Hi. And ready examples here - https://github.com/blynkkk/blynk-library/tree/master/examples/GettingStarted

2 Likes

I am getting my a$$$$ woooped, I am super brain fried right now uggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhhhhhh :slight_smile: this is super complicated stuff, I can program in arduino well and am learning to use the photons cloud functions but attaching a simple variable to a v register is proving to turn every hair on my head grey so it feels LOL please help me.

@fisvii You are familiar with programming Arduinos, so you understand the basic concept of a variable, right?

A virtual pin is a variable that the App and hardware use to pass data between each other.

Compare this rough example (not including any pinmode setup, etc.) of a Physical Button to a Button Widget in Blynk App, both lighting a Physical LED.

// This function is called by something in your sketch, timer or other loop
void ButtonCheck()  
{
  val = digitalRead(inPin);   // read the input pin
  digitalWrite(ledPin, val);    // sets the LED to the button's value
}


// This function is called by pressing (and releasing) the Button Widget in your app
BLYNK_WRITE(vPin)  
{
  val = (param.asInt());   // read the input (as an integer) from Button Widget set to vPin
  digitalWrite(ledPin, val);    // sets the LED to the button's value
}

http://docs.blynk.cc/#blynk-firmware-virtual-pins-control-blynk_writevpin

And in reverse, you can assign a value to “value” (or whatever you designate) and send it to App widgets like a Display Widget using commands like Blynk.virtualWrite(vPin, value)

http://docs.blynk.cc/#blynk-firmware-virtual-pins-control-blynkvirtualwritevpin-value

1 Like

Thanks bud, I seem to be having problems, I’m using particle photon, and I don’t know why I cant, get this to write, I’m using the 01 particle.ino example from the Blynk libraries on the particle IDE. This seems to work fine when I use blynk to control or read a digital pin like d7 the onboard led pin, works great. I think my problem is I don’t know for sure how to add a working Blynk Library to an already existing/ working photon program. I’m not sure if or how to do this, I think alot of my problem may be how particle imports the libraries, it tends to add the #include library name for you, but the .H and .CPP files it attaches do not contain any code, I’ve had to copy from the github .H and .cpp folders to get the libraries to actually work in the past. In the case of this blynk library it appears to have alot of supporting libraries. I do know THe example in the particle community seems to include all these extra supporting libraries itleast in the 01Particle.INO example when you use it. Blynk works great. But I’m slightly confused how to get the Blynk library added into an existing photon project that is already debugged and working. I’ve only been playing with this Blynk for 2 days now, but seems this is going to prove to be very difficult to do with Photon. Arduino may be the easier route but then I don’t have any esp wifi experience so perhaps not. Well I’m going to try and use your example adding it to the 01particle.INO example on proton. THanks for the time and response, I’m sure it will help me to eventually conquer these minor issues. Mike

I’ve got a simple virtual pin reading from the photon and the firmware is also working now with the Blynk, I’d like to thank everyone who took the time to help me to get this far, your references saved me much time. Appreciated truly. Thanks again. I’m loving this blynk and photon now :slight_smile:

3 Likes