BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Blynk output app

Hello

First sorry my engglish is bad

In example programs esp8266 i have: Blynk.run() in void loops
So i can control digital output from apk in my phone

Because its very simple program(Blynk.run()) how i cant read what pin i press in button apk and what logic in that pin now?

Example:
I want to know how i write this program in Blynk librarys:

If(digitalRead(2)==HIGHT)
{
Serial.print(“button 2, pin 2 is press”)
}
else
{
Serial.print(“button 2, pin 2 is not press”)

}

=======

Thanks

If you attach the app widget to a virtual pin, then when the value of the widget changes it triggers the BLYNK_WRITE(vPin) callback.
The value of the widget can then be captured using the param.asInt() command.

If you take a look at the virtual pin examples in the sketch builder then you’ll see some examples.

Pete.