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

Using VIrtual buttons

Could a simple sketch be loaded of using virtual buttons in the BLYNK EXAMPLES on the arduino ide .
I have spent MANY HOURS , the main error is “PARAM” was not declared.
the one listed on the BLYNK comunity shows the same error,ther must be hundred of people using it , but i just
cannot get it to work. what i need are 2 virtual buttons switching on/off 2 digital pins , i have arduino and esp8266-12.
THANKS in advance.

What do you have so far?

I am trying to use the example using VIRTUAL BUTTONS after failing to understand the code.

my virtual button is(v5);
digital pin i am trying to switch is (D5),
or (D6), pin 12, or pin 14 arduino ide,
i dont understand what the line ( param.asInt()) do.

Below is a copy off code i have seen every where which give the error. the links to GITHUB ,with more examples gives 404 error

} BLYNK_WRITE(4);
if (param.asInt()) //{
digitalWrite(12, HIGH);
} else {
digitalWrite(12, LOW);
// }

There are things going really haywire there. Can you please post your entire code (except auth-token and wifi info). Use the <\> button or three backticks (```) before and after your code to make it readable on this forum.

if the line was written correctly it would be checking if the virtual pin is high or low (1 or 0).
this is the correct syntax of the function:

BLYNK_WRITE(V4){
  if (param.asInt()) {
    digitalWrite(12, HIGH);
  } else {
    digitalWrite(12, LOW);
  }
}

You don’t have to use V4, 4 is ok but I like to see the V prefix.

3 posts were split to a new topic: I want to control 1 relay or digital pin from wemos