I need to get data from a slider and process it outside the BLYNK_WRITE function.
I tried simply assign it in a variable like x = param.asInt(), but as expected, it doesn’t work. As i barely know about c, it doesn’t allow to use variables from a function to another unless you use address arrays as input, and the BLYNK_WRITE has only the virtual pin input. Am I wrong? because i did see people doing like this in other posts, but I don’t know if it worked for them. it certainly didn’t work for me. The device keep connecting and disconnecting from server.
I thought about reading directly from the pins or using them as a bridge by writing in them inside the BLYNK_WRITE function and then reading it in the loop function, but the slider can’t use analog pins, I tried the pulseIn() function for reading pwm signals from the digital pin without succes, and i don’t know any function for reading from a virtual pin.
My project would be a simple temperature controller with a heater and a cooler connected. The sliders would set the maximum and mínimum temperature limits saying when to switch the heater or the cooler on/off. So if there are any different ways to do so, i would be happy to know.
glad for the help!
I think this may be a good example:
I think there is some working code inside that thread. Not sure if it’s possible to proces it outside of the function though.
Thank you for the reply. That is exactly the example that i said that i’ve seen using the assign method, but it didn’t work for me, and I’m not sure it worked for him too. It is ok to compile, but the Blynk server couldn’t run it and disconnect the device.
Are you using local or globar vars? I think it should work with global, but as Dmitriy said, pleas share your code so we can look at it.
Never mind. Sory about that. I was wrong. Simple assing works fine. The problem was that i was calling Blynk.virtualWrite function inside the loop function, that was a bad idea. Now it is in the BLYNK_READ function and it works fine. Thank u guys!