Dear friends,
I need your help. I want to use virtual V200 pin, V201, V202, but they don’t work, how do they work? Thank you friends. best wishes to you.
BLYNK_WRITE(V200)
{
if (param.asInt() == 0)
{
Serial.println("1111");
}
if (param.asInt() == 1)
{
Serial.println("2222");
}
I’ve never has to use BLYNK_WRITE_DEFAULT(), but according to he who knows everything, its not quite the way you’ve described:
In the example @Gunner gives, it seems that request.pin returns the pin that triggered the BLYNK_WRITE_DEFAULT() callback:
BLYNK_WRITE_DEFAULT() {
int pin = request.pin; // determines what vPin is triggering this response
if (param.asInt() == 1) {
Serial.print("Button on Virtual Pin ");
Serial.print(pin); // Display the number of the vPin
Serial.println(" is pressed");
} else {
// Do something, or nothing, when button is OFF
}
}
so if you had different code that ran for V200, V201, V202 then you’d need to use a series of ‘if’ statements, or a Select Case statement.
But @Gunner s using request.pin to discover which pin triggered the callback. He happens to be storing it in an integer called pin, but it seems to me that it’s the request.pin keyword that’s the critical part.
As I said, I’ve never used it, and not tested either bits of code so I could be wrong.
Please don’t attempt to tag multiple Blynk staff members in your posts on this forum. They are very busy, and monitor the forum when they have the opportunity, but they won’t get involved in answering questions like this, especially when the answer has already been provided.
Tagging people in this way will get your membership of this forum suspended.
We’ve already shown you that the solution is to use BLYNK_WRITE_DEFAULT() instead of BLYNK_WRITE(V200), and that request.pin will return the number of the pin that triggered the BLYNK_WRITE_DEFAULT callback.
Sorry, it won’t be in the future, it works, thank you very much and Blynk_Coeur for your help, and thank you for the blynk staff members who are silently paying.