NodeMCU Blink test works incorrect

Hi all!
I have just tried learning Arduino, so I've started with simple Blink test.

define LED_BUILTIN D4
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  //digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  //delay(5000);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  //delay(500);                      // wait for a second
}

As we can see, I commented all commads in the loop function, so the embeded LED of NodeMCU have been starting turn on in all time without blinking. As I understand this command (LOW) should turn off the LED. So my question is: Why does the LED's light stable without blink?

Welcome to the forum.

You are asking a simple question, but that raises ten times more questions :face_with_spiral_eyes:
Are you using a NodeMCU ESP8266 ? And you have installed that board in the Arduino IDE and you can upload a sketch to it ? That's great!

The "LED_BUILTIN" is already defined, you should not change that.

A delay of 5000 milliseconds is 5 seconds, that is a long time. Yet the comment says "wait for a second". Those minor details are important if you want to write good code :nerd_face:

You could be looking at the power led, or your board does not have a led builtin led. Maybe it is a weird board that has the led that turns on when the output is LOW. Anything is possible.

My best guess: You might have a normal and common ESP8266 board, but then picked the wrong board from the list in the Arduino IDE and selected a board that does not have a led and "LED_BUILTIN" is not defined. Can you give a link to your board and can you tell which board you have selected ?

Hello Koepel! Thanks! I use NodeMCU v3 CH340 controller with built in LED on D4 pin.
In Boards Manager I picked up NodeMCU 1.0 (ESP-12E Module)

I think that is the most common ESP8266 board, that is good.
Do you use the Arduino IDE 2.0 ?
With this for the ESP8266 in the preferences ?

https://arduino.esp8266.com/stable/package_esp8266com_index.json

In the Arduino IDE 2.0, in the menu "Tools", you can see many settings for that board. There is even an option to select pin 2 or 16 for the led.

I have a Lolin NodeMCU V3 ESP8266, and the led blinks when I select pin 2.
The led is off with a HIGH and on with a LOW.
So the led is indeed connected to the 3.3V, similar to this schematic:
afbeelding

Conclusion: What you found is indeed the case. A LOW turns the led on. The pinMode() defaults to a LOW output.

1 Like

Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE

Hello @Koepel! Greate thanks for your attention to my issue.

Yes, it is.

In my case pin 2

That is qustion for me. Why does the led is off with a HIGH?

In the IDE's standart sketch for testing blinking builtin LED there is comment:

The led on the Arduino Uno turns on with a HIGH, and perhaps all other Arduino boards as well.

The NodeMCU is not an Arduino board, it is Arduino-"compatible". The manufacturer of the board decided that the led is on with a LOW. That's just how it is.

1 Like

@Koepel Thx!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.