i use the Blynk app to control my Photon.
i want to write on a virtual pin.
it works well when i write it like this
Blynk.virtualWrite(V2, “write an example on virtual pin number 2”);
but i don’t understand how i can write to the pin data.
for example, let say i have an integer “n” which i want to write to the virtual pin.
i tried to write it like this
Blynk.virtualWrite(V2, n);
but it doesn’t work
in anyway i try, the app just stops working.
There are 2 ways to avoid it, depending on what you need.
If you need to get data from hardware only when you use your app - use this. For example to check what’s the temperature right now.
If you need hardware to constantly push data even if the app is offline. For example you need to log the temperature - you would need to use some timer library to make timed events (e.g. send data every min). I use SPARKCOREPOLLEDTIMER library for that.
There is an example for Arduino, but SPARKCOREPOLLEDTIMER works very similar.