Hello, I’m trying to build IOT Christmas ornaments using a Particle Photon. I’d like them to be controlled via the Blynk app. There are a few things I want them to be able to do:
Change colours depending on what I set in the Blynk app
Blink in a pattern that I set in the Blynk app
Change colours in a pattern I set in the Blynk app
In order to do all this, I need to be able to write code that can detect which button is pressed in the app.
So, I guess my big questions is how do I reference the button that’s in my GUI (in the Blynk app) in my code?
Thanks for the reply. I’ve been spending some time reading them and I’m still a bit confused.
I REALLY wish they just had a virtualRead command!!!
They have virtualWrite but no Read?!?!?!
It’s kinda ridiculous!!
I did find another forum post that said the solution is to use state syncing but I really don’t see how that’s a viable solution. Then, I found a post that said using param.asInt() will read a virtual pin.
However, I can’t figure out how to set which virtual pin I want to read. And, I can’t figure out how to read multiple virtual pins.
Again, thank you so much for the reply and the advice.
BLYNK_WRITE(V1) // Button Widget is writing to pin V1
{
int pinData = param.asInt(); //assign value from pin to variable called pinData
if (pinData == 1){
//do something when button is pressed
} esle if (pinData == 0){
// do something else when button is released
}
}
I figured it out, thank you very much for your time and efforts!!
The Blynk forums are one of the best forums I’ve found so far!
Thank you all for your help.