Virtual Status LED

Hello People!

I am currently working on a project in which I am using Blynk to controle an LED.
Now I got everything working great, however, I want to take it one step further by adding a Virtual Status LED on my Phone.
I’ve been trying to use the virtualWrite function but I just didn’t seem to get it right.

    void loop()
{
  Blynk.run();
  int input=Blynk.digitalRead(0);
    if (input=HIGH){
      Blynk.virtualWrite(1,HIGH);
      }
      if (input=LOW){
      Blynk.virtualWrite(1,LOW);
      }
  
  
}

Please bare with me, I am relatively new to this.

Any help would be highly appreciated.

Thank you in advance.
Jocobes

Hi, try to use this code OUT of the void loop:

BLYNK_READ(1) // Led at V1 as Input
{
if (digitalRead(4) == HIGH) { // if your digital input is high
led1.on();
} else {
led1.off();
}
}

Kind regards

I don’t quite understand your code:

-where does “led1” come from?

-also wouldn’t the pin at BLYNK_READ and digital read have to be the same one?

Nevermind, I got it working. Thank you for your help though!

void loop()
{
  Blynk.run();
  
if (digitalRead(0) == HIGH) {
  Blynk.virtualWrite(1,HIGH);
  } 
else {Blynk.virtualWrite(1,LOW);
  }

}

Jocobes

I think it should be

See LED example.