Still Can't Get Virtual Pins Working

I have been trying to get Virtual Pins working as discussed in this thread, but it is just not lighting the LED in the Blynk app. Other output pins are responding to Blynk controls, and the onboard LED (pin 5) and Serial writes are working as expected per the code below.

Any thoughts? Thanks.

char auth[] = "xxxxx";
char ssid[] = "xxxxx";
char pass[] = "xxxxx";
int testVal = 0;
int timer;


void setup() {
  Serial.begin(115200);
  pinMode(5, OUTPUT);
  Blynk.begin(auth, ssid, pass);
  timer = millis();
}

void loop()
{
  if (millis() - timer > 2000) {
    timer = millis();
    testVal = 1 - testVal;
    Serial.println(testVal);
    if(testVal) {
      digitalWrite(5, HIGH);
      Blynk.virtualWrite(1, HIGH);
    } else {
      digitalWrite(5, LOW);
      Blynk.virtualWrite(1, LOW);
    }
  }
  Blynk.run();
}

Please try using Blynk.virtualWrite(1, 255);
Sorry, it’s not documented anywhere…

also check LED example in the library. There is a special function for LED widget

Thanks for the info. Using 255 and 0 in Blynk.virtualWrite instead of HIGH and LOW worked.

The special LED widget functions look interesting. Even the fact that you can define Blynk widgets within the firmware is interesting. I will have to explore those further in the coming days.

1 Like