Blink the Built-in LED
void setup() {
  pinMode(2, OUTPUT);
}


void loop() {
  digitalWrite(2, HIGH);  
  delay(1000);                          
  digitalWrite(2, LOW);   
  delay(1000);                          
}

 

In NodeMCU, GPIO2 is mapped to D4 and is connected to the built-in LED. This means that when you use GPIO2 for other purposes, the built-in LED will be affected, as it shares the same pin.
 

In ESP-01, GPIO2 controls the built-in LED. When you use GPIO2 for other tasks, the built-in LED will be impacted, since it's connected to the same pin.


NodeMCU
ESP-01


06 Nov. 2024 | Last Updated: 22 Nov. 2025 | jaimedcsilva

Related
  • How to Set Up Arduino IDE for ESP8266 Development
  • Blink the Built-in LED
  • Connecting the ESP8266 to Wi-Fi
  • Measuring Wi-Fi Signal Strength (RSSI) with ESP8266
  • ESP-01 ≡ How to program an ESP-01?
  • ESP-01 ≡ Detecting I2C Devices
  • ESP-01 ≡ TX button and an RX LED
  • ESP-01 ≡ Blink external LED on GPIO0
  • NodeMCU ≡ Blink external LED on D0
  • NodeMCU ≡ Detecting I2C Devices

  • Buy Me a Coffee