digitalWrite virtual pin NodeMCU dosen`t work

I’m using a nodemcu and i have tried to turn on a LED via Virtual Pin.
I have already tried with D5 instead of 5.
I can not find my mistake.
I can turn on the LED with the direct way but not with the virtual pin mode and I need this for my main project.
I also tryed to debug it with the Serial Monitor. There I could read the Virtual pin just the LED won’t turn on.

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = “89189043dd3c4494a82f469624ce7b6e”;
char ssid[] = “T13Fritz”;
char pass[] = “”;

void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pinMode(5, OUTPUT);
}

BLYNK_WRITE(V2)
{
int buttonState = param.asInt();
digitalWrite(5, buttonState);
}

void loop()
{
Blynk.run();
}

I just postet this simple sketch to show my problem.

d5 is not a physical 5 output!!
pinMode (5, OUTPUT) = d1(nodemcu ).

Thanks for the fast answer.
But i have already tried it with D5 like i said.

digitalWrite(D5, buttonState);

You are not understanding… With ESP8266 boards, the silkscreen pin D5 is NOT pin 5 in Arduino code… it is actually pin 14. This is the number you want to use in your code.

Here is a list of pins and their potential issues

3 Likes

Thank you a lot with 14 it actually works.
But in a sketch without Blynk i can also wright it with D5.
Just with blynk there is a Problem with D5.

F.e.:

void setup() {
pinMode(D5, OUTPUT);
}
void loop() {
digitalWrite(D5, HIGH);
delay(1000);
digitalWrite(D5, LOW); .
delay(1000);
}

That works.

Sorry for my bad English. :smiley:

Arduino IDE will recognise the Dx silkscreened pin numbering if the correct board type is chosen (even with Blynk… which is just a library, not a programming language). Thus the IDE still compiles Dx just fine, but the number in the Dx is NOT the same as the GPIO numbering (AKA using just the number in the code). Still best to always use the standardised GPIO numbering.