ESP8266 LED is lit at LOW and off at HIGH

Hi,
I have the following problem. When connecting a WeMod D1 mini and linking a button on Blynk with a led, when the button on blynk is OFF the led is lit and when the blynk button is ON the led is not lit. I understand this has something to do with pullup resistors inside esp8266 but how can I make the button on the app to show the actual status of the led not the opposite (i dont want to rename the button label inside blynk app) ?
Thank you.

Use Virtual Pins and reverse the logic on your button:

BLYNK_WRITE(V0)
{
  if(param.asInt()
  {
    digitalWrite(ledPin, LOW);
  }
  else
  {
    digitalWrite(ledPin, HIGH);
  }
}
1 Like

Or shorthanded… :slight_smile:

BLYNK_WRITE(V0)
{
  if(param.asInt()
  {
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
}

Thank you for answering.
I want to do something more:
If I press the button to change the state, i want to not be able to change it again for 1 minute, the buton must be turn red and after one minute, the button turn green an allows me to press it again.
Can I do that ?

Yes.

1 Like

Of course you can. It just requires a bit of thinking of how the program flow would go. Try and act like a machine if you think about software coding. The hardware is really stupid, it only does what you tell it to do, no matter how wrong it is (debug anyone … ).

Make a flow chart, it helps a lot to :slight_smile: With a creative mind anything is possible in this crazy world.

I’ve already did it (with minute() and syncall) but it is in revers. I will try to change with !digitalRead(ledPin))