BLYNK_WRITE(0) // At global scope (not inside of the function)
{
int i=param.asInt();
if (i==1)
{
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
}
else
{
digitalWrite(12, HIGH);
digitalWrite(13, LOW);
}
}
I have beginner question. How can i use buttons on off if button is on fan will on else fan will off can you give codes of this example but all parts of the code for example i attached the fan pin to digital write 6 and how can i on or off this pin by using blynk button
Technically the else if (y == 0) can be simply an else because with Blynk button widgets the functions are only called when you press or release the button.
This topic is over 4 years old. You may be better off creating a new topic.
In regards to your question. It should be BLYNK_WRITE(V0). You also do not need the Blynk.run(); in the function. The virtual button by default will output a 1 when pressed, and a 0 when not pressed/released. So if your virtual button has the default settings the analogWrite commands will be executed upon release of the button.
BLYNK_WRITE(V0)
{
int i=param.asInt();
if (i==0)
{
analogWrite(6,0);
analogWrite(9,0);
analogWrite(11,0);
}
else
{
//do nothing
}
}